home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / PGM_TOOL / PREVIEW / SAMPLES / JBDET.PAS < prev    next >
Pascal/Delphi Source File  |  1995-10-29  |  68KB  |  2,399 lines

  1. unit JobDetails;
  2.  
  3. interface
  4.  
  5.   uses DBFserver, wPreview, CommonCode, JcCommon;
  6.  
  7.     type
  8.  
  9.     JDrec=Class(TObject)
  10.         private
  11.           { following used to track aliases used
  12.               by "jbfstart" found in jccommon.pas }
  13.             dbfsrc,curjob,lastjob:integer;
  14.             labor,outside,history,partclas,vendors,emp:oDB;
  15.       parts,jobs,due,ship,cust,tools,jipinfo,jobitems:oDB;
  16.             { vars used by Job Detail routines }
  17.       ftot_labor,absval,comtot,tot1,tot2:double;
  18.             actcnt,estcnt,invset,mcnt,pcnt,rdcnt,rdsmax,rscnt:integer;
  19.       mpcnt,ecnt,specicnt,ddcnt,sscnt,due_cnt,ship_cnt,showscnt:integer;
  20.       shocom1,shocom2,shocom3,no_emps,depcnt,rtcnt:integer;
  21.       sstot,ssdue,tot_ship,tot_due:double;
  22.       job_bid,tot_job,tot_mat,tot_proc:double;
  23.             matwt,procwt:double;
  24.       ejob_tot,job_tot,commtot,acttot:double;
  25.       ssldate,sslinvdt,curr_date:longint;
  26.             thisjob,adjcom1,adjcom2:string[120];
  27.             donewline,hadzero,shotstot:boolean;
  28.       shocom:boolean;
  29.             ssldue,sslship:longint;
  30.             tot_labor,ssship,ssadj,etot_mat,etot_proc,ssmat,ssproc,hjob_tot:double;
  31.             dlist:array [1..100] of longint;
  32.             slist:array [1..100] of longint;
  33.             actlist:array [1..10] of string135;
  34.             estlist:array [1..10] of string135;
  35.             empa:array [1..12] of double;
  36.             empar:array [1..12] of string[5];
  37.             subtot:array [1..12] of double;
  38.             tot:array [1..12] of double;
  39.             mlist:array [1..150] of longint;
  40.             plist:array [1..150] of longint;
  41.             trate:array [1..15] of double;
  42.             trtot:array [1..15] of double;
  43.             dephrs:array [1..20] of double;
  44.             deplist:array [1..20] of string[5];
  45.             deptot:array [1..20] of double;
  46.             apclas:array [1..10] of string[5];
  47.             acost_ea:array [1..10] of double;
  48.             acost_lb:array [1..10] of double;
  49.             actual:array [1..10] of string[3];
  50.             apnote:array [1..10] of string[30];
  51.             ehours:array [1..50] of double;
  52.             enum:array [1..50] of string[4];
  53.             eperc:array [1..50] of double;
  54.             jp:lpr;
  55.             tjob:jobrec;
  56.             procedure JDstop;
  57.             procedure jbfstart(use_arch:integer);
  58.             function  calccomm(cfor:string):double;
  59.             procedure fillactest;
  60.             procedure incline;
  61.             procedure jbdthead;
  62.             procedure jdmain;
  63.             procedure jdsumbox;
  64.             procedure labordt;
  65.             procedure lstdueship;
  66.             function  lvblank(vv:double):string;
  67.             procedure mpsel(mp:integer;choice:double);
  68.             procedure oddinvoices;
  69.             procedure outsidt;
  70.             procedure prtarray(prtot:boolean);
  71.             procedure shosummary(addon:boolean);
  72.             procedure shosumtots;
  73.             procedure showcomments(shonum:integer);
  74.             function  showsum(atline:integer):integer;
  75.             procedure prjbdetail;
  76.             procedure fastjbd;
  77.             procedure fdueship;
  78.             procedure falabor;
  79.             procedure faoutside;
  80.             procedure fsumbox;
  81.             procedure faoutsidt;
  82.             procedure fajdsumbox;
  83.             procedure fashowest(lnum:integer);
  84.             procedure ldpcosts;
  85.             procedure cloz5dbfs;
  86.         public
  87.             histonly,sumsonly,sumdets,hardcopy,shortform:boolean;
  88.             sumarr:array [1..3] of double;
  89.             sumlist:string[120];
  90.             constructor Create;
  91.             procedure PrintDetails(var jlist:array of string40);
  92.             procedure histupdate(pJobRec:JobRec);
  93.         end;
  94.  
  95.  
  96. implementation
  97.  
  98. constructor JDrec.Create;
  99. var ii:integer;
  100. begin
  101.     tjob:=JobRec.Create;
  102.     Jp:=Lpr.Create;
  103.     labor:=Nil;
  104.     outside:=Nil;
  105.     history:=Nil;
  106.     partclas:=Nil;
  107.     vendors:=Nil;
  108.     emp:=Nil;
  109.     parts:=Nil;
  110.     jobs:=Nil;
  111.     due:=Nil;
  112.     ship:=Nil;
  113.     cust:=Nil;
  114.     tools:=Nil;
  115.     jipinfo:=Nil;
  116.     jobitems:=Nil;
  117.     sumsonly:=False;  { fast detail }
  118.   sumdets:=false;   { sum detail results }
  119.   hardcopy:=false;  { these are hardcopies print then close }
  120.     histonly:=false;  { do not print report, only format it }
  121.     shortform:=False;  { leave false, show labor or ship detail }
  122.     for ii:=1 to 3 do sumarr[ii]:=0;
  123.   sumlist:=' ';
  124.     if pos(Upper(Gen.User),'ERNIE RICK ')>0 then begin
  125.         sumsonly:=True;
  126.     End;
  127. end;
  128.  
  129. procedure JDrec.JDstop;
  130. begin
  131.     jp.free;
  132.     tjob.free;
  133. end;
  134.  
  135. procedure JDrec.PrintDetails(var jlist:array of string40);
  136. var ii,kk:integer;
  137.     TryAgain:boolean;
  138. begin
  139.     jbfstart(1);  {  open non rotating files needed }
  140.     jbfstart(4);  {  open main Job Detail files needed }
  141.     jp.SetDestination;
  142.   lastjob:=high(jlist);
  143.   for ii:=0 to High(jlist) do begin
  144.     if not empty(jlist[ii]) then begin
  145.       lastjob:=ii;
  146.     end;
  147.   end;
  148.   for ii:=0 to lastjob do begin
  149.         DoEvents2;
  150.     curjob:=ii; { used to track when to print final summary }
  151.     thisjob:=padr(substr(jlist[ii],1,10),10);
  152.     TryAgain:=true;
  153.     kk:=0;
  154.     while TryAgain do begin
  155.       DoEvents2;
  156.       pp(kk);
  157.       tjob.jobs:=jobs;
  158.       tjob.due:=due;
  159.       tjob.ship:=ship;
  160.       tjob.labor:=labor;
  161.       tjob.outside:=outside;
  162.       tjob.vendors:=vendors;
  163.       tjob.cust:=cust;
  164.       tjob.parts:=parts;
  165.       tjob.tools:=tools;
  166.       tjob.jipinfo:=jipinfo;
  167.       tjob.jobitems:=jobitems;
  168.       if jobs.Seek(thisjob) then begin
  169.         tjob.load(thisjob,false);
  170.         if sumsonly then begin
  171.           fastjbd;
  172.           TryAgain:=False;
  173.           kk:=0;
  174.         end else
  175.         begin
  176.           prjbdetail;
  177.           TryAgain:=False;
  178.           kk:=0;
  179.         End;
  180.       end else begin
  181.         case dbfsrc of
  182.           4:begin
  183.               jbfstart(2);
  184.             end;
  185.           2:begin
  186.               jbfstart(3);
  187.             end;
  188.           3:begin
  189.               jbfstart(4);
  190.             end;
  191.         end;
  192.       end;
  193.       if kk=3 then begin
  194.         OKbox(trim(thisjob)+' Not Found');
  195.         TryAgain:=false; { only try 3 different areas }
  196.       end;
  197.     end;
  198.   end;
  199.   jbfstart(-1);  {  close unneeded files }
  200. end;
  201.  
  202.  
  203. procedure JDrec.prjbdetail;
  204. begin
  205.   { vars used by sumsonly routine }
  206.   mpcnt:=0;
  207.   ecnt:=0;
  208.   specicnt:=0;
  209.   sstot:=0.00;
  210.   ssmat:=0.00;
  211.   ssproc:=0.00;
  212.   ssship:=0.00;
  213.   ssadj:=0.00;
  214.   ssdue:=0.00;
  215.   matwt:=0;
  216.   procwt:=0;
  217.   tjob.otherup:=0;
  218.   tjob.otherchgs:=0;
  219.   sslship:=0;
  220.   sslinvdt:=0;
  221.   ssldue:=xDate;
  222.   mpcnt:=0;
  223.   jp.Page:=1;
  224.   jp.line:=1;
  225.   ddcnt:=2;
  226.   sscnt:=2;
  227.   tot_ship:=0;
  228.   due_cnt:=0;
  229.   ship_cnt:=0;
  230.   tot_due:=0;
  231.   job_bid:=0.00;
  232.   tot_job:=0.00;
  233.   etot_mat:=0.00;
  234.   etot_proc:=0.00;
  235.   tot_mat:=0.00;
  236.   tot_proc:=0.00;
  237.   hjob_tot:=0.00;
  238.   job_tot:=0.00;
  239.   tot_labor:=0.00;
  240.   jobs.Seek(thisjob);
  241.   if Not parts.Seek(jobs.s('part_no')+jobs.s('job_no')) then begin
  242.     parts.Seek(jobs.s('part_no'));
  243.   End;
  244.   cust.Seek(trim(jobs.s('cust_no')));
  245.   due.Seek(trim(thisjob));
  246.   ship.Seek(trim(thisjob));
  247.     jp.StartDoc(for14x11,trim(thisjob)+' Job Detail');
  248.   jbdthead;
  249.   jdmain;
  250.   lstdueship;
  251.   labordt;
  252.   outsidt;
  253.   if Gen.AtPDS then begin
  254.     if jp.line+11>=jp.PgLen then begin
  255.       jp.line:=jp.line + 20;
  256.       incline;
  257.     End;
  258.   end else incline;
  259.   jdsumbox;
  260.   if (sumdets) and (curjob=lastjob) then begin
  261.     if not histonly then shosummary(True);
  262.   End;
  263.   jp.StopDoc;  { done formatting job detail report }
  264.   if histonly then begin
  265.     if (sumdets) and (curjob=lastjob) then shosummary(false);
  266.   end;
  267.   { histupdate(tjob,tjd); }
  268. end;
  269.  
  270.  
  271. procedure JDrec.jbdthead;
  272. begin
  273.   jp.line:=1;
  274.   jp.p(jp.line,1,upper(Gen.CompanyName));
  275.   jp.p(jp.line,58,'JOB DETAIL REPORT');
  276.   if jobs.f('jstatus')>0 then begin
  277.     if jobs.f('jstatus')=1 then begin
  278.       jp.p(jp.line,97,'CANCELLED: ');
  279.     end else
  280.     begin
  281.       if jobs.f('jstatus')=2 then begin
  282.         jp.p(jp.line,97,'COMPLETED: ');
  283.       end else
  284.       begin
  285.         if jobs.f('jstatus')=3 then begin
  286.           if jobs.d('statdate')=0 then begin
  287.               jp.p(jp.line,93,'CLOSED BY: '+ jobs.s('clozapprov')+' ');
  288.           end else jp.p(jp.line,97,'CLOSED: ');
  289.         end;
  290.       end;
  291.     End;
  292.     jp.p(jp.line,jp.pCol,ltrim(datehyph(jobs.d('statdate'))));
  293.   End;
  294.   jp.p(pp(jp.line),118,'DATE: '+ltrim(datehyph(xDate)));
  295.   if Gen.AtPDS then begin
  296.     jp.p(jp.line,1,'FOR '+Gen.User);
  297.   End;
  298.   jp.p(jp.line,58,replicate('-',17));
  299.   if jobs.f('jstatus')>0 then begin
  300.     if jobs.f('jstatus')=3 then begin
  301.       jp.p(jp.line,97,'H A R D   C O P Y');
  302.     End;
  303.   End;
  304.   jp.p(pp(jp.line),118,'PAGE: '+ltrim(transform(jp.Page,'999')));
  305.     pp(jp.line);
  306.  
  307.   jp.p(jp.line,1,'JOB NUMBER');
  308.   jp.p(jp.line,14,'CUSTOMER NAME');
  309.   jp.p(jp.line,42,'QUANTITY');
  310.   jp.p(jp.line,53,'PART NUMBER');
  311.   jp.p(jp.line,78,'******* DUE *******');
  312.   jp.p(jp.line,100,'*********** SHIPPED ************');
  313.   incline;
  314.  
  315.   if Gen.AtPDS then begin
  316.     jp.p(jp.line,1,'DIV');
  317.     jp.p(jp.line,7,'DEP');
  318.   end else jp.p(jp.line,1,'DEP');
  319.   jp.p(jp.line,14,'CUSTOMER PO#');
  320.   jp.p(jp.line,40,'UNIT PRICE');
  321.   jp.p(jp.line,53,'PART NAME');
  322.   jp.p(jp.line,80,'QUANTITY');
  323.   jp.p(jp.line,91,'DATE');
  324.   jp.p(jp.line,102,'QUANTITY');
  325.   jp.p(jp.line,113,'DATE');
  326.   jp.p(jp.line,120,'INV DATE');
  327.   jp.p(jp.line,129,'VIA');
  328.   incline;
  329.  
  330.   jp.p(jp.line,1,replicate('-',10));
  331.   jp.p(jp.line,14,replicate('-',24));
  332.   jp.p(jp.line,40,replicate('-',10));
  333.   jp.p(jp.line,53,replicate('-',20));
  334.   jp.p(jp.line,78,replicate('-',10));
  335.   jp.p(jp.line,89,replicate('-',8));
  336.   jp.p(jp.line,100,replicate('-',10));
  337.   jp.p(jp.line,111,replicate('-',8));
  338.   jp.p(jp.line,120,replicate('-',8));
  339.   jp.p(jp.line,129,'---');
  340.   incline;
  341.   incline;
  342. end;
  343.  
  344.  
  345. procedure JDrec.jdmain;
  346. begin
  347.   jp.p(jp.line,1,replicate('*',10));
  348.   jp.p(jp.line,53,replicate('*',20));
  349.   incline;
  350.   jp.p(jp.line,1,thisjob);
  351.   jp.p(jp.line,14,Copy(cust.s('name'),1,25));
  352.   jp.p(jp.line,39,transform(jobs.f('qty'),'999,999,999'));
  353.   jp.p(jp.line,53,trim(jobs.s('part_no')));
  354.   if Not empty(jobs.s('rev_no')) then begin
  355.     jp.p(jp.line,jp.pCol,'  '''+trim(jobs.s('rev_no'))+'''');
  356.   End;
  357.   if Not jobs.d('mot_date')=0 then begin
  358.     jp.p(jp.line,jp.pCol,' MOT '+ltrim(datehyph(jobs.d('mot_date'))));
  359.   End;
  360.   if Not empty(jobs.s('joblink')) then begin
  361.     jp.p(jp.line,86,'** ALSO SEE JOB '+trim(jobs.s('joblink')));
  362.   End;
  363.   incline;
  364.   jp.p(jp.line,1,replicate('*',10));
  365.   jp.p(jp.line,53,replicate('*',20));
  366.   incline;
  367.   if Gen.AtPDS then begin
  368.     jp.p(jp.line,2,jobs.s('div_no'));
  369.     jp.p(jp.line,7,jobs.s('dep'));
  370.   end else jp.p(jp.line,1,jobs.s('dep'));
  371.   jp.p(jp.line,14,jobs.s('po_no'));
  372.   tjob.otherup:=0;
  373.   tjob.otherchgs:=0;
  374.   if jobs.f('unit_price')<0 then begin
  375.     jp.p(jp.line,38,transform(abs(jobs.f('unit_price')),'9,999.99')+'/LOT');
  376.   end else
  377.   begin
  378.     jp.p(jp.line,38,transform(jobs.f('unit_price')+
  379.           tjob.otherup,'999,999.9999'));
  380.   End;
  381.   jp.p(jp.line,53,parts.s('name'));
  382.   incline;
  383.   incline;
  384.   { if not Gen.AtPDS then begin }
  385.     { oddinvoices }
  386.   { end; }
  387. end;
  388.  
  389.  
  390. procedure JDrec.oddinvoices;
  391. begin
  392.   { arhist.Seek(trim(cutjobno(jobs.s('job_no')))); }
  393. end;
  394.  
  395.  
  396. procedure JDrec.showcomments(shonum:integer);
  397. begin
  398.   if shonum=1 then begin
  399.     jp.p(jp.line,10,'NOTE:');
  400.     jp.p(jp.line,16,jp.specchars(jobs.s('note')));
  401.   end else
  402.   begin
  403.     if shonum=2 then begin
  404.       if Not empty(jobs.s('note2')) then begin
  405.         jp.p(jp.line,16,jp.specchars(jobs.s('note2')));
  406.       End;
  407.     end else
  408.     begin
  409.       if shonum=3 then begin
  410.         if Not empty(jobs.s('note3')) then begin
  411.           jp.p(jp.line,16,jp.specchars(jobs.s('note3')));
  412.         End;
  413.       end;
  414.     end;
  415.   End;
  416. end;
  417.  
  418.  
  419. procedure JDrec.lstdueship;
  420. var ii:integer;
  421. begin
  422.     for ii:=1 to 100 do dlist[ii]:=0;
  423.     for ii:=1 to 100 do slist[ii]:=0;
  424.   rdcnt:=0;
  425.   rscnt:=0;
  426.   if due.Seek(jobs.s('job_no')) then begin
  427.     While (Not due.Eof) And (jobs.s('job_no')=due.s('job_no')) do begin
  428.             DoEvents2;
  429.       pp(rdcnt);
  430.       dlist[rdcnt]:=due.RecNo;
  431.       due.Skip;
  432.     end;
  433.   End;
  434.   if ship.Seek(jobs.s('job_no')) then begin
  435.     While (Not ship.Eof) And (jobs.s('job_no')=ship.s('job_no')) do begin
  436.             DoEvents2;
  437.       hadzero:=False;
  438.       pp(rscnt);
  439.       slist[rscnt]:=ship.RecNo;
  440.       if ship.f('qty')=0 then begin
  441.        ship.Lock;
  442.        ship.ss('job_no',space(10));
  443.        ship.unLock;
  444.        hadzero:=True;
  445.       End;
  446.       ship.Skip;
  447.       if hadzero then begin  { start over }
  448.         rscnt:=0;
  449.                 for ii:=1 to 100 do slist[ii]:=0;
  450.         if Not ship.Seek(jobs.s('job_no')) then begin
  451.           break;
  452.         End;
  453.       End;
  454.     End;
  455.   End;
  456.   if rscnt>rdcnt then rdsmax:=rscnt
  457.     else rdsmax:=rdcnt;
  458.   shocom1:=0;
  459.   shocom2:=0;
  460.   shocom3:=0;
  461.   if rdsmax>0 then begin
  462.     for ii:=1 to rdsmax do begin
  463.             DoEvents2;
  464.       donewline:=False;
  465.       if (ii<=rdcnt) And (dlist[ii]>0) then begin
  466.         due.Go(dlist[ii]);
  467.         if due.s('job_no')=jobs.s('job_no') then begin
  468.           if shocom1=0 then begin
  469.             showcomments(1);
  470.             shocom1:=jp.line;
  471.             donewline:=True;
  472.           end else
  473.           begin
  474.             if shocom2=0 then begin
  475.               showcomments(2);
  476.               shocom2:=jp.line;
  477.               donewline:=True;
  478.             end else
  479.             begin
  480.               if shocom3=0 then begin
  481.                 showcomments(3);
  482.                 shocom3:=jp.line;
  483.                 donewline:=True;
  484.               End;
  485.             End;
  486.           End;
  487.           if Not shortform then begin
  488.             jp.p(jp.line,77,
  489.                           transform(due.f('qty'),'999,999,999'));
  490.             jp.p(jp.line,89,datehyph(due.d('fdate')));
  491.             donewline:=True;
  492.           End;
  493.           if ssldue=xDate then begin
  494.             ssldue:=due.d('fdate');
  495.           End;
  496.           tot_due:=tot_due + due.f('qty');
  497.         End;
  498.       End;
  499.       if (ii<=rscnt) And (slist[ii]>0) then begin
  500.         ship.Go(slist[ii]);
  501.         if ship.s('job_no') = ship.s('job_no') then begin
  502.           if shocom1=0 then begin
  503.             showcomments(1);
  504.             shocom1:=jp.line;
  505.             donewline:=True;
  506.           end else
  507.           begin
  508.             if (shocom2=0) And (shocom1<>jp.line) then begin
  509.               showcomments(2);
  510.               shocom2:=jp.line;
  511.               donewline:=True;
  512.             end else
  513.             begin
  514.               if (shocom3=0) And (shocom1<>jp.line) And (shocom2<>jp.line)
  515.                             then begin
  516.                 showcomments(3);
  517.                 shocom3:=jp.line;
  518.                 donewline:=True;
  519.               End;
  520.             End;
  521.           End;
  522.           if Not shortform then begin
  523.             jp.p(jp.line,99,
  524.                           transform(ship.f('qty'),'999,999,999'));
  525.             jp.p(jp.line,111,datehyph(ship.d('fdate')));
  526.             jp.p(jp.line,120,datehyph(ship.d('inv_date')));
  527.             jp.p(jp.line,129,ship.s('ship_via'));
  528.             donewline:=True;
  529.           End;
  530.           sslship:=ship.d('fdate');
  531.           sslinvdt:=ship.d('inv_date');
  532.           tot_ship:=tot_ship + ship.f('qty');
  533.         End;
  534.       End;
  535.       if donewline then begin
  536.         incline;
  537.       End;
  538.     End;
  539.   End;
  540.   ssdue:=tot_due;
  541.   ssship:=tot_ship;
  542.   showscnt:=0;
  543.   if shocom1=0 then begin
  544.     showcomments(1);
  545.     incline;
  546.     showcomments(2);
  547.     showscnt:=showsum(showscnt);
  548.     incline;
  549.     showcomments(3);
  550.     showscnt:=showsum(showscnt);
  551.     incline;
  552.     shocom2:=jp.line;
  553.     shocom3:=jp.line;
  554.   End;
  555.   if shocom2=0 then begin
  556.     showcomments(2);
  557.     showscnt:=showsum(showscnt);
  558.     incline;
  559.     showcomments(3);
  560.     showscnt:=showsum(showscnt);
  561.     incline;
  562.     shocom3:=jp.line;
  563.   End;
  564.   if shocom3=0 then begin
  565.     showcomments(3);
  566.     showscnt:=showsum(showscnt);
  567.     incline;
  568.   End;
  569.   incline;
  570.   jp.p(jp.line,1,'EMPLOYEE LABOR TOTALS THIS JOB:');
  571.   if showscnt<2 then begin
  572.     showscnt:=showsum(showscnt);
  573.   End;
  574.   incline;
  575.   if showscnt<2 then begin
  576.     showscnt:=showsum(showscnt);
  577.     incline;
  578.   End;
  579. end;
  580.  
  581. function JDrec.showsum(atline:integer):integer;
  582. begin
  583.     pp(atline);
  584.     if atline=1 then begin
  585.         if tot_ship>0 then begin
  586.             jp.p(jp.line,100,replicate('-',10));
  587.             if shortform then begin
  588.                 jp.p(jp.line,112,'LAST SHIP '+datehyph(sslship));
  589.             End;
  590.         End;
  591.     end else
  592.     begin
  593.         if atline=2 then begin
  594.             if tot_ship>0 then begin
  595.                 jp.p(jp.line,99,transform(tot_ship,'999,999,999'));
  596.                 sumarr[3]:=sumarr[3]+tot_ship;
  597.                 if shortform then begin
  598.                     jp.p(jp.line,112,'LAST INV. '+datehyph(sslinvdt));
  599.                 End;
  600.             End;
  601.         end;
  602.     End;
  603.     Result:=atline;
  604. end;
  605.  
  606.  
  607. procedure JDrec.labordt;
  608. var ii,i,j:integer;
  609.     ll:longint;
  610. begin
  611.   labor.Seek(trim(thisjob));
  612.   no_emps:=0;
  613.     for ii:=1 to 12 do empa[ii]:=0;
  614.     for ii:=1 to 12 do tot[ii]:=0;
  615.     for ii:=1 to 12 do subtot[ii]:=0;
  616.     for ii:=1 to 20 do deptot[ii]:=0;
  617.     for ii:=1 to 20 do deplist[ii]:='   ';
  618.     for ii:=1 to 20 do dephrs[ii]:=0;
  619.     for ii:=1 to 12 do empar[ii]:='   ';
  620.     for ii:=1 to 50 do enum[ii]:='   ';
  621.     for ii:=1 to 50 do ehours[ii]:=0;
  622.     for ii:=1 to 50 do eperc[ii]:=0;
  623.     for ii:=1 to 15 do trate[ii]:=0;
  624.     for ii:=1 to 15 do trtot[ii]:=0;
  625.   depcnt:=0;
  626.   ecnt:=0;
  627.   rtcnt:=0;
  628.   curr_date:=ctod(' ');
  629.   While labor.s('job_no') = thisjob do begin
  630.         DoEvents2;
  631.     curr_date:=labor.d('trans_date');
  632.     While (labor.d('trans_date') = curr_date) And (labor.s('job_no') = thisjob) do begin
  633.             DoEvents2;
  634.       ll:=labor.RecNo;
  635.       j:=0;
  636.       for i:=1 to 12 do begin
  637.         if labor.s('emp_no') = empar[i] then begin
  638.           j:=i;
  639.           break;
  640.         End;
  641.       End;
  642.       if j=0 then begin
  643.         pp(no_emps);
  644.         if no_emps = 13 then begin
  645.           if Not shortform then begin
  646.             prtarray(True);
  647.           End;
  648.           no_emps:=1;
  649.           for i:=1 to 12 do begin
  650.             empar[no_emps]:='   ';
  651.           End;
  652.         End;
  653.         empar[no_emps]:=labor.s('emp_no');
  654.         empa[no_emps]:=empa[no_emps] + labor.f('hours');
  655.         tot[no_emps]:=tot[no_emps] + labor.f('hours');
  656.         subtot[no_emps]:=subtot[no_emps] + labor.f('hours');
  657.       end else
  658.             begin
  659.         empa[j]:=empa[j] + labor.f('hours');
  660.         tot[j]:=tot[j] + labor.f('hours');
  661.         subtot[j]:=subtot[j] + labor.f('hours');
  662.       End;
  663.       j:=0;
  664.       if ecnt>0 then begin
  665.         for i:=1 to ecnt do begin
  666.           if labor.s('emp_no')=enum[i] then begin
  667.             j:=i;
  668.             break;
  669.           End;
  670.         End;
  671.       End;
  672.       if j>0 then begin
  673.         eperc[j]:=eperc[j]+labor.f('hours');
  674.         ehours[j]:=ehours[j]+labor.f('hours');
  675.       end else
  676.             begin
  677.         if ecnt<50 then begin
  678.           pp(ecnt);
  679.           enum[ecnt]:=labor.s('emp_no');
  680.           eperc[ecnt]:=labor.f('hours');
  681.           ehours[ecnt]:=labor.f('hours');
  682.         End;
  683.       End;
  684.       emp.Seek(labor.s('emp_no'));
  685.       j:=0;
  686.       if depcnt>0 then begin
  687.         for i:=1 to depcnt do begin
  688.           if emp.s('depart')=deplist[i] then begin
  689.             j:=i;
  690.             break;
  691.           End;
  692.         End;
  693.       End;
  694.       if j=0 then begin
  695.         pp(depcnt);
  696.         deplist[depcnt]:=emp.s('depart');
  697.         j:=depcnt;
  698.       End;
  699.       deptot[j]:=deptot[j]+labor.f('rate')*labor.f('hours');
  700.       dephrs[j]:=dephrs[j]+labor.f('hours');
  701.       j:=0;
  702.       if rtcnt>0 then begin
  703.         for i:=1 to rtcnt do begin
  704.           if labor.f('rate')=trate[i] then begin
  705.             j:=i;
  706.             break;
  707.           End;
  708.         End;
  709.       End;
  710.       if j>0 then begin
  711.         trtot[j]:=trtot[j]+labor.f('hours');
  712.       end else
  713.       begin
  714.         if rtcnt<50 then begin
  715.           pp(rtcnt);
  716.           trate[rtcnt]:=labor.f('rate');
  717.           trtot[rtcnt]:=labor.f('hours');
  718.         End;
  719.       End;
  720.       if labor.Eof then begin
  721.         break;
  722.       End;
  723.       labor.Skip;
  724.     end;
  725.     if Not shortform then begin
  726.       prtarray(False);
  727.     End;
  728.     if labor.Eof then begin
  729.       break;
  730.     End;
  731.   end;
  732.   if Not shortform then begin
  733.     prtarray(True);
  734.   End;
  735.   shosumtots;
  736. end;
  737.  
  738.  
  739. procedure JDrec.shosummary(addon:boolean);
  740. begin
  741.   if addon then begin
  742.     jp.p(jp.line,1,padc('SUMMARY FOR JOBS:'+trim(sumlist),132));
  743.     jp.p(jp.line+2,55,'TOTAL BID'+transform(sumarr[1],'999,999,999.99'));
  744.     jp.p(jp.line+3,54,'TOTAL COST'+transform(sumarr[2],'999,999,999.99'));
  745.     jp.p(jp.line+4,53,'TOTAL PARTS'+transform(sumarr[3],'999,999,999.99'));
  746.     if sumarr[3]>0 then begin
  747.       jp.p(jp.line+6,55,'UNIT COST'+transform(sumarr[2]/sumarr[3],'999,999.9999'));
  748.     end else
  749.         begin
  750.       jp.p(jp.line+6,55,'UNIT COST'+transform(0,'999,999.9999'));
  751.     End;
  752.     jp.line:=jp.line+6;
  753.   end else
  754.     begin
  755.       jp.StartDoc(for8x11,'Detail Summary');
  756.     jp.p(2,1,padc('PART DETAIL SUMMARY REPORT',79));
  757.     jp.p(2,71,datehyph(xDate));
  758.     jp.p(4,1,padc('FOR JOBS:'+trim(sumlist),79));
  759.     jp.p(6,28,'TOTAL BID'+transform(sumarr[1],'999,999,999.99'));
  760.     jp.p(7,27,'TOTAL COST'+transform(sumarr[2],'999,999,999.99'));
  761.     jp.p(8,26, 'TOTAL PARTS'+transform(sumarr[3],'999,999,999.99'));
  762.     if sumarr[3]>0 then begin
  763.       jp.p(10,28,'UNIT COST'+transform(sumarr[2]/sumarr[3],'9,999,999.9999'));
  764.     end else
  765.         begin
  766.       jp.p(10,28,'UNIT COST'+transform(0,'9,999,999.9999'));
  767.     End;
  768.     jp.StopDoc;
  769.   End;
  770. end;
  771.  
  772. procedure JDrec.incline;
  773. begin
  774.     pp(jp.line);
  775.     if jp.line>=jp.PgLen then begin
  776.         jp.Page:=jp.Page + 1;
  777.         jp.Eject;
  778.         jp.line:=1;
  779.         jp.p(jp.line,1,upper(Gen.CompanyName));
  780.         jp.p(jp.line,58,'JOB DETAIL REPORT');
  781.         jp.p(pp(jp.line),118,'DATE: '+ltrim(datehyph(xDate)));
  782.         jp.p(jp.line,1,'***********************');
  783.         jp.p(jp.line,58,'-----------------');
  784.         jp.p(pp(jp.line),118,'TIME: '+upper(ltrim(longtime)));
  785.         jp.p(jp.line,1,thisjob+' CONTINUED...');
  786.         jp.p(pp(jp.line),118,'PAGE: '+ltrim(transform(jp.Page,'999')));
  787.         jp.p(jp.line,1,'***********************');
  788.         jp.line:=jp.line+2;
  789.     End;
  790. end;
  791.  
  792.  
  793. procedure JDrec.prtarray(prtot:boolean);
  794. var dotots,shostot:boolean;
  795.     i,j:integer;
  796. begin
  797.   shostot:=False;
  798.   dotots:=False;
  799.   if (no_emps>=12) Or (prtot) then begin
  800.     dotots:=True;
  801.   End;
  802.   j:=0;
  803.   for i:=1 to 12 do begin
  804.     if empa[i]>0 then begin
  805.       j:=i;
  806.       break;
  807.     End;
  808.   End;
  809.   if j>0 then begin
  810.     jp.p(jp.line,1,datehyph(curr_date));
  811.     for i:=1 to 12 do begin
  812.       if empa[i]>0 then begin
  813.         jp.p(jp.line,(i*10)+2,transform(empa[i],'99.99'));
  814.       End;
  815.       empa[i]:=0;
  816.     End;
  817.     incline;
  818.   End;
  819.   if Not dotots then begin
  820.     if jp.line>=jp.PgLen then begin
  821.       shostot:=True;
  822.     End;
  823.   End;
  824.   j:=0;
  825.   for i:=1 to 12 do begin
  826.     if tot[i]>0 then begin
  827.       j:=i;
  828.       break;
  829.     End;
  830.   End;
  831.   if j=0 then begin
  832.     dotots:=False;
  833.   End;
  834.   j:=0;
  835.   for i:=1 to 12 do begin
  836.     if subtot[i]>0 then begin
  837.       j:=i;
  838.       break;
  839.     End;
  840.   End;
  841.   if j=0 then begin
  842.     shostot:=False;
  843.   End;
  844.   if (dotots) Or (shostot) then begin
  845.     if dotots then begin
  846.       jp.p(jp.line,1,'TOTALS:');
  847.     end else
  848.         begin
  849.       jp.p(jp.line,0,'SUBTOTAL:');
  850.     End;
  851.     for i:=1 to 12 do begin
  852.       if dotots then begin
  853.         if tot[i]>0 then begin
  854.           jp.p(jp.line,(i*10)+1,transform(tot[i],'999.99'));
  855.         End;
  856.       end else
  857.             begin
  858.         if subtot[i]>0 then begin
  859.           jp.p(jp.line,(i*10)+1,transform(subtot[i],'999.99'));
  860.         End;
  861.       End;
  862.     End;
  863.         pp(jp.line);
  864.     jp.p(jp.line,1,'EMP NO:');
  865.     for i:=1 to 12 do begin
  866.       if dotots then begin
  867.         if tot[i]>0 then begin
  868.           jp.p(jp.line,(i*10)+2,empar[i]);
  869.         End;
  870.       end else
  871.             begin
  872.         if subtot[i]>0 then begin
  873.           jp.p(jp.line,(i*10)+2,empar[i]);
  874.         End;
  875.       End;
  876.     End;
  877.         pp(jp.line);
  878.     for i:=1 to 12 do begin
  879.       if dotots then begin
  880.         if tot[i]>0 then begin
  881.           if emp.Seek(trim(empar[i])) then begin
  882.             jp.p(jp.line,i*10,shortename(emp.s('name'),5));
  883.           End;
  884.         End;
  885.       end else
  886.             begin
  887.         if subtot[i]>0 then begin
  888.           if emp.Seek(trim(empar[i])) then begin
  889.             jp.p(jp.line,i*10,shortename(emp.s('name'),5));
  890.           End;
  891.         End;
  892.       End;
  893.       if dotots then begin
  894.         tot[i]:=0.00;
  895.         subtot[i]:=0.00;
  896.         empar[i]:='   ';
  897.       end else
  898.             begin
  899.         subtot[i]:=0.00;
  900.       End;
  901.     End;
  902.         pp(jp.line);
  903.     incline;
  904.   End;
  905. end;
  906.  
  907.  
  908. procedure JDrec.outsidt;
  909. var ii,yy:integer;
  910. begin
  911.     for ii:=1 to 150 do mlist[ii]:=0;
  912.     for ii:=1 to 150 do plist[ii]:=0;
  913.   mcnt:=0;
  914.   pcnt:=0;
  915.   tot_mat:=0.00;
  916.   tot_proc:=0.00;
  917.   if jp.line+4>=jp.PgLen then begin
  918.     jp.line:=jp.line+10;
  919.     incline;
  920.   End;
  921.   jp.p(jp.line,1,replicate('*',23)+' MATERIALS '+replicate('*',29));
  922.   jp.p(jp.line,71,replicate('*',22)+' OUTSIDE PROCESS '+replicate('*',22));
  923.   incline;
  924.   jp.p(jp.line,3,'DATE');
  925.   jp.p(jp.line,10,'VENDOR#');
  926.   jp.p(jp.line,19,'VENDOR NAME');
  927.   jp.p(jp.line,41,'INVOICE NO');
  928.   jp.p(jp.line,53,'INVOICE AMT');
  929.   jp.p(jp.line,73,'DATE');
  930.   jp.p(jp.line,80,'VENDOR#');
  931.   jp.p(jp.line,89,'VENDOR NAME');
  932.   jp.p(jp.line,110,'INVOICE NO');
  933.   jp.p(jp.line,121,'INVOICE AMT');
  934.   incline;
  935.   if outside.Seek(thisjob) then begin
  936.     While (Not outside.Eof) And (thisjob=outside.s('job_no')) 
  937.         do begin
  938.             DoEvents2;
  939.       if outside.s('cost_type')='M' then begin
  940.         pp(mcnt);
  941.         mlist[mcnt]:=outside.RecNo;
  942.       End;
  943.       if outside.s('cost_type')='P' then begin
  944.         pp(pcnt);
  945.         plist[pcnt]:=outside.RecNo;
  946.       End;
  947.       outside.Skip;
  948.     End;
  949.   End;
  950.   { append requests for commissions at end of processing array }
  951.   pp(pcnt);
  952.   plist[pcnt]:=-1;
  953.   pp(pcnt);
  954.   plist[pcnt]:=-2;
  955.   for yy:=1 to 150 do begin
  956.     commtot:=0;
  957.     if mlist[yy]>0 then begin
  958.             DoEvents2;
  959.       outside.Go(mlist[yy]);
  960.       vendors.Seek(outside.s('vendor_no'));
  961.       jp.p(jp.line,1,datehyph(outside.d('trans_date')));
  962.       jp.p(jp.line,10,outside.s('vendor_no'));
  963.       jp.p(jp.line,19,upper(Copy(vendors.s('name'),1,20)));
  964.       jp.p(jp.line,41,outside.s('invoice_no'));
  965.       absval:=outside.f('inv_amount');
  966.       jp.p(jp.line,53,transform(absval,'999,999.99'));
  967.       tot_mat:=tot_mat + absval;
  968.     End;
  969.     if plist[yy]<>0 then begin
  970.       if plist[yy]>0 then begin
  971.                 DoEvents2;
  972.         outside.Go(plist[yy]);
  973.         vendors.Seek(outside.s('vendor_no'));
  974.         jp.p(jp.line,71,datehyph(outside.d('trans_date')));
  975.         jp.p(jp.line,80,outside.s('vendor_no'));
  976.         jp.p(jp.line,89,upper(Copy(vendors.s('name'),1,20)));
  977.         jp.p(jp.line,110,outside.s('invoice_no'));
  978.         jp.p(jp.line,121,transform(outside.f('inv_amount'),'999,999.99'));
  979.         tot_proc:=tot_proc+outside.f('inv_amount');
  980.         commtot:=outside.f('inv_amount');  { needed to force incline below }
  981.       end else
  982.             begin
  983.         if plist[yy]=-1 then begin
  984.           comtot:=calccomm('1');
  985.           if comtot>0 then begin
  986.             jp.p(jp.line,89,'TONY ROCCO - COMMISSION');
  987.             jp.p(jp.line,121,transform(comtot,'999,999.99'));
  988.             tot_proc:=tot_proc + comtot;
  989.           End;
  990.         end else
  991.                 begin
  992.                     if plist[yy]=-2 then begin
  993.                         comtot:=calccomm('2');
  994.                         if comtot>0 then begin
  995.                             jp.p(jp.line,89,'GEORGE MUSIL - COMMISSION');
  996.                             jp.p(jp.line,121,transform(comtot,'999,999.99'));
  997.                             tot_proc:=tot_proc + comtot;
  998.                         End;
  999.                     End;
  1000.                 end;
  1001.       End;
  1002.     End;
  1003.     if (mlist[yy]<>0) Or (commtot<>0) then begin
  1004.       incline;
  1005.     End;
  1006.   End;
  1007.   incline;
  1008.   jp.p(jp.line,53,replicate('-',11));
  1009.   jp.p(jp.line,121,replicate('-',11));
  1010.   incline;
  1011.   jp.p(jp.line,29,'TOTAL MATERIAL COST:');
  1012.   jp.p(jp.line,51,transform(tot_mat,'9,999,999.99'));
  1013.   if Gen.AtPDS then begin
  1014.     mpsel(1,1);
  1015.   End;
  1016.   jp.p(jp.line,90,'TOTAL PROCESSING COST:');
  1017.   if Gen.AtPDS then begin
  1018.     mpsel(2,1);
  1019.   End;
  1020.   jp.p(jp.line,119,transform(tot_proc,'9,999,999.99'));
  1021.   jp.line:=jp.line + 1;
  1022.   ldpcosts;  { set mpcnt, apclas[], in epart.prg }
  1023.   etot_mat:=0;
  1024.   etot_proc:=0;
  1025.   if mpcnt>0 then begin
  1026.     for yy:=1 to mpcnt do begin
  1027.       partclas.Seek(apclas[yy]);
  1028.             if actual[yy]='L' then begin
  1029.                 etot_proc:=etot_proc + acost_ea[yy];
  1030.             end else begin
  1031.                 if (partclas.s('mat_proc')='M') Or (partclas.s('mat_proc')='C') 
  1032.                 then begin
  1033.                     etot_mat:=etot_mat + (acost_ea[yy]*tot_ship);
  1034.                 end else
  1035.                 begin
  1036.                     etot_proc:=etot_proc + (acost_ea[yy]*tot_ship);
  1037.                 end;
  1038.       End;
  1039.     End;
  1040.   End;
  1041.   if Gen.AtPDS then begin
  1042.     jp.p(jp.line,39,'ESTIMATED:');
  1043.     jp.p(jp.line,51,lvblank(etot_mat));
  1044.     mpsel(1,2);
  1045.     jp.p(jp.line,102,'ESTIMATED:');
  1046.     mpsel(2,2);
  1047.     jp.p(jp.line,119,lvblank(etot_proc));
  1048.     jp.line:=jp.line + 1;
  1049.     jp.p(jp.line,34,'ADJUSTED TOTAL:');
  1050.     jp.p(jp.line,51,lvblank(jobs.f('mater_est')));
  1051.     mpsel(1,3);
  1052.     jp.p(jp.line,97,'ADJUSTED TOTAL:');
  1053.     mpsel(2,3);
  1054.     jp.p(jp.line,119,lvblank(jobs.f('proc_est')));
  1055.   end else
  1056.     begin
  1057.     {  jp.line = jp.line + 1 }
  1058.     {  @ jp.line,39 say "ESTIMATED:" }
  1059.     {  @ jp.line,51 say lvblank(jobs.f('mater_est')); }
  1060.     {  @ jp.line,102 say "ESTIMATED:" }
  1061.     {  @ jp.line,119 say lvblank(jobs.f('proc_est')) }
  1062.   End;
  1063.   incline;
  1064.   incline;
  1065.   ssmat:=tot_mat;
  1066.   if jobs.f('matsel') = 2 then begin
  1067.     ssmat:=etot_mat;
  1068.   end else
  1069.   if jobs.f('matsel') = 3 then begin
  1070.     ssmat:=jobs.f('mater_est');
  1071.   End;
  1072.   ssproc:=tot_proc;
  1073.   if jobs.f('procsel') = 2 then begin
  1074.     ssproc:=etot_proc;
  1075.   end else
  1076.   if jobs.f('procsel') = 3 then begin
  1077.     ssproc:=jobs.f('proc_est');
  1078.   End;
  1079. end;
  1080.  
  1081.  
  1082. procedure JDrec.jdsumbox;
  1083. var ii,lli:integer;
  1084.     tt:string;
  1085. begin
  1086.     for ii:=1 to 10 do actlist[ii]:='*'+space(63)+'* *'+space(38)+'*';
  1087.     for ii:=1 to 10 do estlist[ii]:='*'+space(63)+'*';
  1088.   estcnt:=0;
  1089.   actcnt:=0;
  1090.   tot1:=0.00;
  1091.   tot2:=0.00;
  1092.   fillactest;
  1093.   sstot:=ssmat + ssproc + tot_labor;
  1094.   adjcom1:=jobs.s('jdnote1');
  1095.   adjcom2:=jobs.s('jdnote2');
  1096.   ejob_tot:=0;
  1097.   if jobs.f('unit_price')<0 then begin
  1098.     job_bid:=abs(jobs.f('unit_price'));
  1099.   end else
  1100.     begin
  1101.     job_bid:=(tot_ship * (jobs.f('unit_price')+
  1102.           tjob.otherup))+tjob.otherchgs;
  1103.   End;
  1104.   if Not Gen.AtPDS then begin
  1105.     job_bid:=jobs.f('qty') * jobs.f('unit_price');
  1106.   End;
  1107.   hjob_tot:=job_tot;
  1108.   job_tot:=tot_labor + tot_mat + tot_proc;
  1109.   ejob_tot:=tot_labor + etot_mat + etot_proc;
  1110.   if Gen.AtPDS then begin
  1111.     if False then begin  { ignore for now }
  1112.       jp.p(jp.line,3,
  1113.               'ACTUAL MATERIAL, PROCESS & OUTSIDE LABOR COST FOR THIS S.O.');
  1114.       jp.p(pp(jp.line),82,'COMMENT');
  1115.       jp.p(jp.line,0,replicate('*',65));
  1116.       jp.p(pp(jp.line),66,replicate('*',40));
  1117.       jp.p(jp.line,0,'*  MATL-PROCESS-LABOR');
  1118.       jp.p(jp.line,23,'LBS/UNIT');
  1119.       jp.p(jp.line,33,'COST/LB');
  1120.       jp.p(jp.line,42,'UNIT COST');
  1121.       jp.p(jp.line,53,'TOTAL COST *');
  1122.       jp.p(pp(jp.line),66,'*'+space(38)+'*');
  1123.       jp.p(jp.line,0,'*  '+replicate('-',18));
  1124.       jp.p(jp.line,23,replicate('-',8));
  1125.       jp.p(jp.line,33,replicate('-',7));
  1126.       jp.p(jp.line,42,replicate('-',9));
  1127.       jp.p(jp.line,53,replicate('-',10)+' *');
  1128.       jp.p(pp(jp.line),66,'*'+space(38)+'*');
  1129.       if acttot>0 then begin
  1130.         for ii:=1 to 6 do begin
  1131.           jp.p(pp(jp.line),0,actlist[ii]);
  1132.         End;
  1133.       end else
  1134.             begin
  1135.         jp.p(pp(jp.line),0,'*'+space(63)+'* *'+space(38)+'*');
  1136.       End;
  1137.       jp.p(jp.line,0,replicate('*',65));
  1138.       jp.p(pp(jp.line),66,replicate('*',40));
  1139.     End;
  1140.  
  1141.     jp.p(jp.line,2,
  1142.           'ESTIMATED MATERIAL, PROCESS & OUTSIDE LABOR COST FOR THIS S.O.');
  1143.     jp.p(jp.line,70,'PARTS AND MATERIAL TO INVENTORY');
  1144.     if jobs.f('unit_price')<0 then begin
  1145.       jp.p(jp.line,108,'LOT PRICE');
  1146.     End;
  1147.         pp(jp.line);
  1148.     jp.p(jp.line,0,replicate('*',65));
  1149.     jp.p(jp.line,66,replicate('*',40));
  1150.     jp.p(jp.line,108,'TOTAL BID:');
  1151.     jp.p(pp(jp.line),119,transform(job_bid,'9,999,999.99'));
  1152.     sumarr[1]:=sumarr[1]+job_bid;
  1153.  
  1154.         jp.p(jp.line,0,'*  MATL-PROCESS-LABOR');
  1155.     jp.p(jp.line,23,'LBS/UNIT');
  1156.     jp.p(jp.line,33,'COST/LB');
  1157.     jp.p(jp.line,42,'UNIT COST');
  1158.     jp.p(jp.line,53,'TOTAL COST *');
  1159.     jp.p(pp(jp.line),66,'*'+space(38)+'*');
  1160.  
  1161.         jp.p(jp.line,0,'*  '+replicate('-',18));
  1162.     jp.p(jp.line,23,replicate('-',8));
  1163.     jp.p(jp.line,33,replicate('-',7));
  1164.     jp.p(jp.line,42,replicate('-',9));
  1165.     jp.p(jp.line,53,replicate('-',10)+' *');
  1166.     jp.p(jp.line,66,'* COMPLETE TO BLUEPRINT :');
  1167.     invset:=0;
  1168.     tt:=ltrim(transform(jobs.f('complete'),'999,999,999'));
  1169.     if length(tt)>invset then begin
  1170.       invset:=length(tt);
  1171.     End;
  1172.     tt:=ltrim(transform(jobs.f('partial'),'999,999,999'));
  1173.     if length(tt)>invset then begin
  1174.       invset:=length(tt);
  1175.     End;
  1176.     tt:=ltrim(transform(jobs.f('material'),'999,999,999'));
  1177.     if length(tt)>invset then begin
  1178.       invset:=length(tt);
  1179.     End;
  1180.     if jobs.f('complete')>0 then begin
  1181.       tt:=ltrim(transform(jobs.f('complete'),'999,999,999'));
  1182.       jp.p(jp.line,96,space(invset-length(tt))+tt);
  1183.     end else
  1184.         begin
  1185.       if jobs.f('jstatus')>0 then begin
  1186.         jp.p(jp.line,96,space(invset-5)+'- 0 -');
  1187.       end else
  1188.             begin
  1189.         jp.p(jp.line,93,replicate('_',11));
  1190.       End;
  1191.     End;
  1192.     jp.p(jp.line,105,'*');
  1193.     jp.p(jp.line,107,'TOTAL COST:');
  1194.     job_tot:=tot_labor;
  1195.     if jobs.f('matsel')=1 then begin
  1196.       job_tot:=job_tot+tot_mat;
  1197.     end else
  1198.     begin
  1199.         if jobs.f('matsel')=2 then begin
  1200.           job_tot:=job_tot+etot_mat;
  1201.         end else
  1202.         begin
  1203.         if jobs.f('matsel')=3 then begin
  1204.           job_tot:=job_tot+jobs.f('mater_est');
  1205.         end Else
  1206.         begin
  1207.           job_tot:=job_tot+tot_mat;
  1208.                 end;
  1209.             end;
  1210.         end;
  1211.         if jobs.f('procsel')=1 then begin
  1212.             job_tot:=job_tot+tot_proc;
  1213.         end else
  1214.         begin
  1215.             if jobs.f('procsel')=2 then begin
  1216.                 job_tot:=job_tot+etot_proc;
  1217.             end else
  1218.             begin
  1219.                 if jobs.f('procsel')=3 then begin
  1220.                     job_tot:=job_tot+jobs.f('proc_est');
  1221.                 end Else
  1222.                 begin
  1223.                     job_tot:=job_tot+tot_proc;
  1224.                 end;
  1225.             end;
  1226.         end;
  1227.     jp.p(pp(jp.line),119,transform(job_tot,'9,999,999.99'));
  1228.     sumarr[2]:=sumarr[2]+job_tot;
  1229.     jp.p(jp.line,0,estlist[1]);
  1230.     jp.p(jp.line,66,'* PARTIALLY COMPLETE    : ');
  1231.     if jobs.f('partial')>0 then begin
  1232.       tt:=ltrim(transform(jobs.f('partial'),'999,999,999'));
  1233.       jp.p(jp.line,96,space(invset-length(tt))+tt);
  1234.     end else
  1235.         begin
  1236.       if jobs.f('jstatus')>0 then begin
  1237.         jp.p(jp.line,96,space(invset-5)+'- 0 -');
  1238.       end else
  1239.             begin
  1240.         jp.p(jp.line,93,replicate('_',11));
  1241.       End;
  1242.     End;
  1243.     jp.p(pp(jp.line),105,'*');
  1244.     jp.p(jp.line,0,estlist[2]);
  1245.     jp.p(jp.line,66,'* LESS : ');
  1246.     if Not empty(jobs.s('less')) then begin
  1247.       jp.p(jp.line,76,jobs.st('less'));
  1248.       jp.p(jp.line,105,'*');
  1249.     end else
  1250.         begin
  1251.       jp.p(jp.line,76,replicate('_',28)+' *');
  1252.     End;
  1253.     if tjob.otherchgs<>0 then begin
  1254.       jp.p(jp.line,107,'BID INCLUDES '+
  1255.         ltrim(transform(tjob.otherchgs,'99,999.99'))+' ADJ.');
  1256.     End;
  1257.         pp(jp.line);
  1258.     jp.p(jp.line,0,estlist[3]);
  1259.     jp.p(jp.line,66,'* LBS. MATERIAL IN STOCK: ');
  1260.     if jobs.f('material')>0 then begin
  1261.       tt:=ltrim(transform(jobs.f('material'),'999,999,999'));
  1262.       jp.p(jp.line,96,space(invset-length(tt))+tt);
  1263.     end else
  1264.         begin
  1265.       if jobs.f('jstatus')>0 then begin
  1266.         jp.p(jp.line,96,space(invset-5)+'- 0 -');
  1267.       End;
  1268.     End;
  1269.     jp.p(pp(jp.line),105,'*');
  1270.     jp.p(jp.line,0,estlist[4]);
  1271.     jp.p(jp.line,66,'*'+replicate('-',38)+'*');
  1272.     jp.p(jp.line,jp.pCol,replicate('*',26));
  1273.  
  1274.               { @ jp.line,107 say "TOTAL COST:" }
  1275.               { @ jp.line,119 say ejob_tot pict "9,999,999.99" }
  1276.  
  1277.         pp(jp.line);
  1278.     jp.p(jp.line,0,estlist[5]);
  1279.     jp.p(pp(jp.line),66,'* COMMENT: '+padl(adjcom1,27)+
  1280.           ' * CLOSE                   *');
  1281.     jp.p(jp.line,0,estlist[6]);
  1282.     if empty(jobs.s('clozapprov')) then begin
  1283.       jp.p(jp.line,66,'* '+padl(adjcom2,36)+' * APPROVAL ____  ________ *');
  1284.     end else
  1285.         begin
  1286.       jp.p(jp.line, 66,'* '+padl(adjcom2,36)+' * APPROVAL:  '+
  1287.         jobs.s('clozapprov')+'  '+dshyph(jobs.d('statdate'))+' *');
  1288.     End;
  1289.           { @ jp.line,107 say "TOTAL COST:" }
  1290.         pp(jp.line);
  1291.     if mpcnt>6 then begin
  1292.       for lli:=7 to mpcnt do begin
  1293.         if lli<=estcnt then begin
  1294.           jp.p(pp(jp.line),0,estlist[lli]);
  1295.         End;
  1296.       End;
  1297.     End;
  1298.     jp.p(jp.line,0,replicate('*',65));
  1299.     jp.p(jp.line,66,replicate('*',40));
  1300.     jp.p(jp.line,jp.pCol,replicate('*',26));
  1301.         pp(jp.line);
  1302.   end else
  1303.     begin
  1304.     jp.p(jp.line,34,'EST LABOR COST:');
  1305.     jp.p(jp.line,51,lvblank(jobs.f('labor_est')));
  1306.     jp.p(jp.line,108,'TOTAL BID:');
  1307.     jp.p(pp(jp.line),119,lvblank(job_bid));
  1308.     jp.p(jp.line,38,'LABOR COST:');
  1309.     jp.p(jp.line,51,transform(tot_labor,'9,999,999.99'));
  1310.     jp.p(jp.line,107,'TOTAL COST:');
  1311.     job_tot:=tot_labor+tot_mat+tot_proc;
  1312.     jp.p(jp.line,119,transform(job_tot,'9,999,999.99'));
  1313.     jp.line:=jp.line+1;
  1314.   End;
  1315. end;
  1316.  
  1317.  
  1318. procedure JDrec.fillactest;
  1319. var ii:integer;
  1320.     tt,ttst:string[132];
  1321. begin
  1322.   actcnt:=0;
  1323.   estcnt:=0;
  1324.   if mpcnt>0 then begin
  1325.     for ii:=1 to mpcnt do begin
  1326.       if Not empty(apclas[ii]) then begin
  1327.         tt:='* ';
  1328.         if partclas.Seek(apclas[ii]) then begin
  1329.           ttst:=partclas.s('descript');
  1330.         end else
  1331.                 begin
  1332.           ttst:=' ';
  1333.         End;
  1334.         tt:=tt+' '+padr(ttst,19);
  1335.         if partclas.s('mat_proc')='P' then begin
  1336.           tt:=tt+transform(procwt,'9999.9999');
  1337.         end else
  1338.                 begin
  1339.           if partclas.s('mat_proc')='M' then begin
  1340.             tt:=tt+transform(matwt,'9999.9999');
  1341.           end else
  1342.           begin
  1343.             tt:=tt+space(9);
  1344.           End;
  1345.         End;
  1346.         tt:=tt+'  '+transform(acost_lb[ii],'9999.99');
  1347.         tt:=tt+'  '+transform(acost_ea[ii],'9999.9999');
  1348.         if Not empty(actual[ii]) then begin
  1349.           tt:=tt+actual[ii];
  1350.         end else
  1351.                 begin
  1352.           tt:=tt+' ';
  1353.         End;
  1354.                 if actual[ii]='L' then begin
  1355.                     tt:=tt+transform(acost_ea[ii],'999,999.99');
  1356.                     tot2:=tot2 + acost_ea[ii];
  1357.                 end else begin
  1358.                     tt:=tt+transform(acost_ea[ii]*tot_ship,'999,999.99');
  1359.                     if (partclas.s('mat_proc')='M') Or (partclas.s('mat_proc')='C')
  1360.                         then begin
  1361.                         tot1:=tot1 + (acost_ea[ii])*tot_ship;
  1362.                     end else
  1363.                     begin
  1364.                         tot2:=tot2 + (acost_ea[ii])*tot_ship;
  1365.                     end;
  1366.         End;
  1367.       End;
  1368.       tt:=tt+'  *';
  1369.       if empty(actual[ii]) then begin
  1370.         estcnt:=estcnt+1;
  1371.         estlist[estcnt]:=tt;
  1372.       end else
  1373.             begin
  1374.           { old style }
  1375.         estcnt:=estcnt+1;
  1376.         estlist[estcnt]:=tt;
  1377.  
  1378.           { new style, not used as yet }
  1379.           { actcnt:=actcnt+1 }
  1380.           { actlist[actcnt]:=tt+" * "+apnote[ii]+" *" }
  1381.       End;
  1382.     End;
  1383.   End;
  1384. end;
  1385.  
  1386.  
  1387. procedure JDrec.shosumtots;
  1388. var tt1,tt2,tt3:double;
  1389.     ti,kk,nn:integer;
  1390.     tt4:string[10];
  1391. begin
  1392.   incline;
  1393.   jp.p(jp.line,1,'NO');
  1394.   jp.p(jp.line,11,'HOURS');
  1395.   jp.p(jp.line,17,'% WRKD');
  1396.   jp.p(jp.line,25,'EMPLOYEE NAME');
  1397.   incline;
  1398.   tot_labor:=0.00;
  1399.   job_tot:=0.00;
  1400.   if ecnt>1 then begin
  1401.     for ti:=1 to ecnt do begin
  1402.       job_tot:=job_tot+ehours[ti];
  1403.     End;
  1404.     if job_tot=0 then begin
  1405.       job_tot:=1;
  1406.     End;
  1407.     for ti:=1 to ecnt do begin
  1408.       eperc[ti]:=(ehours[ti]/job_tot)*100;
  1409.     End;
  1410.     for kk:=1 to ecnt do begin
  1411.       for nn:=1 to ecnt-1 do begin
  1412.         if sumsonly then begin
  1413.           if eperc[nn]<eperc[nn+1] then begin
  1414.             tt4:=enum[nn+1];
  1415.             tt2:=eperc[nn+1];
  1416.             tt3:=ehours[nn+1];
  1417.             enum[nn+1]:=enum[nn];
  1418.             eperc[nn+1]:=eperc[nn];
  1419.             ehours[nn+1]:=ehours[nn];
  1420.             enum[nn]:=tt4;
  1421.             eperc[nn]:=tt2;
  1422.             ehours[nn]:=tt3;
  1423.           End;
  1424.         end else
  1425.                 begin
  1426.           if Gen.AtPDS then begin
  1427.             if enum[nn]>enum[nn+1] then begin
  1428.               tt4:=enum[nn+1];
  1429.               tt2:=eperc[nn+1];
  1430.               tt3:=ehours[nn+1];
  1431.               enum[nn+1]:=enum[nn];
  1432.               eperc[nn+1]:=eperc[nn];
  1433.               ehours[nn+1]:=ehours[nn];
  1434.               enum[nn]:=tt4;
  1435.               eperc[nn]:=tt2;
  1436.               ehours[nn]:=tt3;
  1437.             End;
  1438.           end else
  1439.                     begin
  1440.             if eperc[nn]>eperc[nn+1] then begin
  1441.               tt4:=enum[nn+1];
  1442.               tt2:=eperc[nn+1];
  1443.               tt3:=ehours[nn+1];
  1444.               enum[nn+1]:=enum[nn];
  1445.               eperc[nn+1]:=eperc[nn];
  1446.               ehours[nn+1]:=ehours[nn];
  1447.               enum[nn]:=tt4;
  1448.               eperc[nn]:=tt2;
  1449.               ehours[nn]:=tt3;
  1450.             End;
  1451.           End;
  1452.         End;
  1453.       End;
  1454.     End;
  1455.   end else
  1456.     begin
  1457.     job_tot:=ehours[1];
  1458.   End;
  1459.   if rtcnt>1 then begin
  1460.     for kk:=1 to rtcnt do begin
  1461.       for nn:=1 to rtcnt-1 do begin
  1462.         if trate[nn]>trate[nn+1] then begin
  1463.           tt1:=trate[nn+1];
  1464.           tt2:=trtot[nn+1];
  1465.           trate[nn+1]:=trate[nn];
  1466.           trtot[nn+1]:=trtot[nn];
  1467.           trate[nn]:=tt1;
  1468.           trtot[nn]:=tt2;
  1469.         End;
  1470.       End;
  1471.     End;
  1472.   End;
  1473.   if ecnt>0 then begin
  1474.     for ti:=1 to ecnt do begin
  1475.       emp.Seek(enum[ti]);
  1476.       jp.p(jp.line,1,emp.s('emp_no'));
  1477.       jp.p(jp.line,8,transform(ehours[ti],'9,999.99'));
  1478.       jp.p(jp.line,17,transform(eperc[ti],'999.99'));
  1479.       jp.p(jp.line,25,Copy(trim(upper(emp.s('name'))),1,23));
  1480.       if ti<=rtcnt then begin
  1481.         jp.p(jp.line,51,transform(trtot[ti],'9,999.99'));
  1482.         jp.p(jp.line,60,'HRS AT');
  1483.         jp.p(jp.line,67,transform(trate[ti],'99.99'));
  1484.         jp.p(jp.line,73,'=');
  1485.         jp.p(jp.line,74,transform(trate[ti] * trtot[ti],'999,999.99'));
  1486.         tot_labor:=tot_labor + (trate[ti]*trtot[ti]);
  1487.       End;
  1488.       if ti<=depcnt then begin
  1489.         if Not sumsonly then begin
  1490.           jp.p(jp.line,91,Copy(upper(ndep(deplist[ti])),1,16));
  1491.           jp.p(jp.line,109,transform(dephrs[ti],'9,999.99')+' HRS');
  1492.           jp.p(jp.line,122,transform(deptot[ti],'999,999.99'));
  1493.         end else
  1494.                 begin
  1495.           jp.p(jp.line,50,Copy(upper(ndep(deplist[ti])),1,16));
  1496.           jp.p(jp.line,68,transform(dephrs[ti],'9,999.99')+' HRS');
  1497.           jp.p(jp.line,81,transform(deptot[ti],'999,999.99'));
  1498.         End;
  1499.       End;
  1500.       incline;
  1501.     End;
  1502.   End;
  1503.   if rtcnt>ecnt then begin
  1504.     for ti:=ecnt+1 to rtcnt do begin
  1505.       jp.p(jp.line,51,transform(trtot[ti],'9,999.99'));
  1506.       jp.p(jp.line,60,'HRS AT');
  1507.       jp.p(jp.line,67,transform(trate[ti],'99.99'));
  1508.       jp.p(jp.line,73,'=');
  1509.       jp.p(jp.line,74,transform(trate[ti] * trtot[ti],'999,999.99'));
  1510.       tot_labor:=tot_labor + (trate[ti]*trtot[ti]);
  1511.       incline;
  1512.     End;
  1513.   End;
  1514.   if Not sumsonly then begin
  1515.     incline;
  1516.     jp.p(jp.line,44,'TOTAL LABOR:');
  1517.     jp.p(jp.line,56,transform(job_tot,'99,999.99'));
  1518.     jp.p(jp.line,66,'HOURS');
  1519.     jp.p(jp.line,73,'=');
  1520.     jp.p(jp.line,74,transform(tot_labor,'999,999.99'));
  1521.     incline;
  1522.   End;
  1523.   incline;
  1524. end;
  1525.  
  1526.  
  1527. procedure JDrec.mpsel(mp:integer;choice:double);
  1528. begin
  1529.   if mp=1 then begin
  1530.         if jobs.f('matsel')=choice then begin
  1531.             jp.p(jp.line,jp.pCol,'  [*]');
  1532.         end else
  1533.         begin
  1534.             jp.p(jp.line,jp.pCol,'  [ ]');
  1535.         End;
  1536.     end else
  1537.   begin
  1538.     if mp=2 then begin
  1539.       if jobs.f('procsel')=choice then begin
  1540.         jp.p(jp.pRow,jp.pCol,'  [*]');
  1541.       end else
  1542.       begin
  1543.         jp.p(jp.pRow,jp.pCol,'  [ ]');
  1544.       End;
  1545.     End;
  1546.   end;
  1547. end;
  1548.  
  1549.  
  1550. function JDrec.lvblank(vv:double):string;
  1551. begin
  1552.   Result:=space(12);
  1553.   if vv>0 then begin
  1554.     Result:=transform(vv,'9,999,999.99');
  1555.   End;
  1556. end;
  1557.  
  1558.  
  1559. function JDrec.calccomm(cfor:string):double;
  1560. var talias:string[15];
  1561.     invoices,hist2:oDB;
  1562. begin
  1563.   invoices:=nil;
  1564.   hist2:=nil;
  1565.   dbUse(invoices,arpath('invoices'));
  1566.   dbUse(hist2,arpath('history'));
  1567.   commtot:=0;
  1568.   if hist2.Seek(trim(thisjob)) then begin
  1569.     While (Not hist2.Eof) And (thisjob=cutjobno(hist2.s('invoice_no'))) do begin
  1570.             DoEvents2;
  1571.       if (hist2.s('trans_type')='I') And (hist2.s('commfor')=cfor)
  1572.             then begin
  1573.         commtot:=commtot+hist2.f('commission');
  1574.       End;
  1575.       hist2.Skip;
  1576.     End;
  1577.   End;
  1578.   if invoices.Seek(trim(thisjob)) then begin
  1579.     While (Not invoices.Eof) And (thisjob=cutjobno(invoices.s('invoice_no'))) do begin
  1580.             DoEvents2;
  1581.       if invoices.s('commfor')=cfor then begin
  1582.         commtot:=commtot+invoices.f('commission');
  1583.       End;
  1584.       invoices.Skip;
  1585.     End;
  1586.   End;
  1587.   dbClose(invoices);
  1588.   dbClose(hist2);
  1589.   Result:=commtot;
  1590. end;
  1591.  
  1592. procedure JDrec.fastjbd;
  1593. var ii:integer;
  1594.     longst:string;
  1595. begin
  1596.   mpcnt:=0;
  1597.   rtcnt:=0;
  1598.   for ii:=1 to 50 do enum[ii]:='   ';
  1599.   for ii:=1 to 50 do ehours[ii]:=0.00;
  1600.   for ii:=1 to 50 do eperc[ii]:=0.00;
  1601.   for ii:=1 to 20 do deptot[ii]:=0.00;
  1602.   for ii:=1 to 20 do dephrs[ii]:=0.00;
  1603.   for ii:=1 to 20 do deplist[ii]:=space(3);
  1604.   ecnt:=0;
  1605.   depcnt:=0;
  1606.   tjob.otherup:=0;
  1607.   tjob.otherchgs:=0;
  1608.   { vars used by sumsonly routine }
  1609.   sstot:=0.00;
  1610.   ssmat:=0.00;
  1611.   ssproc:=0.00;
  1612.   ssship:=0.00;
  1613.   ssadj:=0.00;
  1614.   ssdue:=0.00;
  1615.   sslship:=ctod(' ');
  1616.   ssldate:=ctod(' ');
  1617.   ssldue:=xDate;
  1618.   mpcnt:=0;
  1619.   tot_ship:=0;
  1620.   tot_due:=0;
  1621.   job_bid:=0.00;
  1622.   tot_job:=0.00;
  1623.   etot_mat:=0.00;
  1624.   etot_proc:=0.00;
  1625.   tot_mat:=0.00;
  1626.   tot_proc:=0.00;
  1627.   hjob_tot:=0.00;
  1628.   job_tot:=0.00;
  1629.   tot_labor:=0.00;
  1630.     { for select file assignments see proc jccommon.prg }
  1631.   jobs.Seek(thisjob);
  1632.   if Not parts.Seek(jobs.s('part_no')+
  1633.             jobs.s('job_no')) then begin
  1634.     parts.Seek(jobs.s('part_no'));
  1635.   End;
  1636.   due.Seek(trim(thisjob));
  1637.   ship.Seek(trim(thisjob));
  1638.   fdueship;
  1639.   falabor;
  1640.   faoutside;
  1641.   adjcom1:=space(28);
  1642.   adjcom2:=space(37);
  1643.   fsumbox;
  1644.  
  1645.     jp.StartDoc(for14x11,trim(thisjob)+' Short Detail');
  1646.   jp.Line := 1;
  1647.   jp.page:=1;
  1648.   longst:='P.O. '+trim(jobs.s('po_no'))+'      P/N '+
  1649.       trim(jobs.s('part_no'));
  1650.   if Not empty(jobs.s('rev_no')) then begin
  1651.     longst:=longst+'  '''+trim(jobs.s('rev_no'))+'''';
  1652.   End;
  1653.   if jobs.d('mot_date')>0 then begin
  1654.     longst:=longst+' MOT '+ltrim(datehyph(jobs.d('mot_date')));
  1655.   End;
  1656.   longst:=longst+'   '+trim(parts.s('name'));
  1657.   jp.p(jp.Line,1,'JOB SUMMARY REPORT');
  1658.   jp.p(jp.Line,20,padc(thisjob,40));
  1659.   jp.p(jp.Line,63,'DATED '+datehyph(xDate));
  1660.   jp.Line:=jp.Line+1;
  1661.   jp.p(jp.Line,1,'------------------');
  1662.   if (jobs.f('jstatus')=1) Or
  1663.       (jobs.f('jstatus')=2) Or
  1664.       (jobs.f('jstatus')=3) then begin
  1665.     if jobs.f('jstatus')=1 then begin
  1666.       jp.p(jp.Line,61,'CANCELLED ');
  1667.     End Else
  1668.     if jobs.f('jstatus')=2 then begin
  1669.       jp.p(jp.Line,61,'COMPLETED ');
  1670.     End Else
  1671.     if jobs.f('jstatus')=3 then begin
  1672.       if jobs.d('statdate')=0 then begin
  1673.         jp.p(jp.line,64,'CLOSED');
  1674.       end else jp.p(jp.line,55,'CLOSED BY: '+ jobs.s('clozapprov')+' ');
  1675.     end;
  1676.     jp.p(jp.Line,jp.pcol,datehyph(jobs.d('statdate')));
  1677.   End;
  1678.   jp.Line:=jp.Line+2;
  1679.   jp.p(jp.Line,1,padc(longst,78));
  1680.   jp.Line:=jp.Line+2;
  1681.   if Gen.AtPDS then begin
  1682.     jp.p(jp.Line,1,'-- INVENTORY --');
  1683.   End;
  1684.   jp.p(jp.Line,28,'  QTY ORDERED '+transform(jobs.f('qty'),'9,999,999'));
  1685.   if jobs.f('unit_price')<0 then begin
  1686.     jp.p(jp.Line,54,'@ '+ltrim(transform(abs(jobs.f('unit_price')),'9,999.99'))+'/LOT');
  1687.     jp.p(jp.pRow,jp.pCol,' := $ '+
  1688.       ltrim(transform(abs(jobs.f('unit_price')),'99,999.99')))
  1689.   End Else
  1690.   Begin
  1691.     jp.p(jp.Line,54,'@ '+ltrim(transform(jobs.f('unit_price')+tjob.otherup,'999,999.9999')));
  1692.     jp.p(jp.pRow,jp.pCol,' := $ '+
  1693.       ltrim(transform(jobs.f('qty')*(jobs.f('unit_price')+tjob.otherup),'9,999,999.99')))
  1694.   End;
  1695.   jp.Line:=jp.Line+2;
  1696.   if Gen.AtPDS then begin
  1697.     jp.p(jp.Line,0,'Comp. B/P '+
  1698.           ltrim(transform(jobs.f('complete'),'99,999,999')));
  1699.   End;
  1700.   jp.p(jp.Line,28,'TOTAL SHIPPED '+transform(ssship,'9,999,999'));
  1701.   sumarr[3]:=sumarr[3]+ssship;
  1702.   if ssship>0 then begin
  1703.     jp.p(jp.pRow,jp.pCol,'   LAST SHIPMENT '+datehyph(sslship));
  1704.   End;
  1705.   jp.Line:=jp.Line+1;
  1706.   if Gen.AtPDS then begin
  1707.     jp.p(jp.Line,2,'Partial '+
  1708.           ltrim(transform(jobs.f('partial'),'99,999,999')));
  1709.     jp.p(jp.pRow,jp.pCol,' Less '+Copy(jobs.s('less'),1,15));
  1710.   End;
  1711.   if ssship>0 then begin
  1712.     jp.p(jp.pRow,55,'LAST INVOICE '+datehyph(ssldate));
  1713.   End;
  1714.   jp.Line:=jp.Line+1;
  1715.   if Gen.AtPDS then begin
  1716.     jp.p(jp.Line,0,'Lbs. Mat. '+
  1717.           ltrim(transform(jobs.f('material'),'99,999')));
  1718.   End;
  1719.   if jobs.f('unit_price')<0 then begin
  1720.     jp.p(jp.Line,30,' TOTAL BID '+transform(abs(jobs.f('unit_price'))+tjob.otherchgs,
  1721.       '999,999.99'));
  1722.   End Else
  1723.   Begin
  1724.     jp.p(jp.Line,30,' TOTAL BID '+transform((ssship*(jobs.f('unit_price')+tjob.otherup))
  1725.       +tjob.otherchgs,'999,999.99'));
  1726.   End;
  1727.   jp.p(jp.Line,54,'BID INCLUDES '+
  1728.     ltrim(transform(tjob.otherchgs,'99,999.99'))+' ADJ.');
  1729.   jp.Line:=jp.Line+2;
  1730.   jp.p(jp.Line,30,'TOTAL COST '+transform(sstot,'999,999.99'));
  1731.   jp.Line:=jp.Line+2;
  1732.   jp.p(jp.Line,29,'TOTAL LABOR '+transform(tot_labor,'999,999.99')+'  ');
  1733.   jp.p(jp.pRow,jp.pCol,ltrim(transform(hjob_tot,'99,999.99')+' Hrs  '));
  1734.   jp.Line:=jp.Line+1;
  1735.   faoutsidt;
  1736.   ftot_labor:=tot_labor;
  1737.   shosumtots;
  1738.   tot_labor:=ftot_labor;
  1739.   incline;
  1740.   fajdsumbox;
  1741.   jp.StopDoc;
  1742.   if jobs.i('jstatus')>0 then begin
  1743.     {histupdate;}
  1744.   End;
  1745. end;
  1746.  
  1747.  
  1748. procedure JDrec.fdueship;
  1749. begin
  1750.   shocom:=True;
  1751.   While due.s('job_no') = jobs.s('job_no')
  1752.     do begin
  1753.         DoEvents2;
  1754.     if ssldue=xDate then begin
  1755.       ssldue := due.d('fdate');
  1756.     End;
  1757.     tot_due := tot_due + due.f('qty');
  1758.     due.Skip;
  1759.   End;
  1760.   While ship.s('job_no') = jobs.s('job_no')
  1761.     do begin
  1762.         DoEvents2;
  1763.     sslship := ship.d('fdate');
  1764.     ssldate := ship.d('inv_date');
  1765.     tot_ship:=tot_ship + ship.f('qty');
  1766.     ship.Skip;
  1767.   End;
  1768.   ssdue := tot_due;
  1769.   ssship := tot_ship;
  1770. end;
  1771.  
  1772.  
  1773. procedure JDrec.falabor;
  1774. var i,j:integer;
  1775. begin
  1776.   labor.Seek(thisjob);
  1777.   While labor.s('job_no') = thisjob do begin
  1778.         DoEvents2;
  1779.     job_tot:=job_tot + labor.f('hours');
  1780.     tot_labor:=tot_labor+(labor.f('hours')*labor.f('rate'));
  1781.     emp.Seek(labor.s('emp_no'));
  1782.     j:=0;
  1783.     if depcnt>0 then begin
  1784.       for i:=1 to depcnt do begin
  1785.         if emp.s('depart')=deplist[i] then begin
  1786.           j:=i;
  1787.           break;
  1788.         End;
  1789.       End;
  1790.     End;
  1791.     if j=0 then begin
  1792.       depcnt:=depcnt+1;
  1793.       deplist[depcnt]:=emp.s('depart');
  1794.       j:=depcnt;
  1795.     End;
  1796.     deptot[j]:=deptot[j]+
  1797.           labor.f('rate')*labor.f('hours');
  1798.     dephrs[j]:=dephrs[j]+labor.f('hours');
  1799.     j:=0;
  1800.     if ecnt>0 then begin
  1801.       for i:=1 to ecnt do begin
  1802.         if labor.s('emp_no')=enum[i] then begin
  1803.           j:=i;
  1804.           break;
  1805.         End;
  1806.       End;
  1807.     End;
  1808.     if j>0 then begin
  1809.       ehours[j]:=ehours[j]+labor.f('hours');
  1810.     End Else
  1811.     Begin
  1812.       if ecnt<50 then begin
  1813.         ecnt:=ecnt+1;
  1814.         enum[ecnt]:=labor.s('emp_no');
  1815.         ehours[ecnt]:=labor.f('hours');
  1816.       End;
  1817.     End;
  1818.     labor.Skip;
  1819.   End;
  1820.   if ecnt>0 then begin
  1821.     if job_tot=0 then begin
  1822.       job_tot:=1;
  1823.     End;
  1824.     for i:=1 to ecnt do begin
  1825.       eperc[i]:= (ehours[i]/job_tot)*100;
  1826.     End;
  1827.   End;
  1828. end;
  1829.  
  1830.  
  1831. procedure JDrec.faoutside;
  1832. var yy:integer;
  1833. begin
  1834.   { job detail report outside costs program }
  1835.   outside.Seek(thisjob);
  1836.   tot_mat:=0.00;
  1837.   tot_proc:=0.00;
  1838.   While thisjob=outside.s('job_no') do begin
  1839.         DoEvents2;
  1840.     if outside.s('cost_type')='M' then begin
  1841.       tot_mat:=tot_mat + outside.f('inv_amount');
  1842.     End;
  1843.     if outside.s('cost_type')='P' then begin
  1844.       tot_proc:=tot_proc + outside.f('inv_amount');
  1845.     End;
  1846.     outside.Skip;
  1847.   End;
  1848.   ldpcosts;  { this proc in epart.prg }
  1849.  
  1850.   etot_mat:=0;
  1851.   etot_proc:=0;
  1852.   if mpcnt>0 then begin
  1853.     for yy:=1 to mpcnt do begin
  1854.       partclas.Seek(apclas[yy]);
  1855.       if (partclas.s('mat_proc')='M') Or (partclas.s('mat_proc')='C') then begin
  1856.         etot_mat:=etot_mat + (acost_ea[yy]*tot_ship);
  1857.       End Else
  1858.       Begin
  1859.         etot_proc:=etot_proc + (acost_ea[yy]*tot_ship);
  1860.       End;
  1861.     End;
  1862.   End;
  1863.   ssmat := tot_mat;
  1864.   if jobs.f('matsel') = 2 then begin
  1865.     ssmat := etot_mat;
  1866.   End Else
  1867.   if jobs.f('matsel') = 3 then begin
  1868.     ssmat := jobs.f('mater_est');
  1869.   End;
  1870.   ssproc := tot_proc;
  1871.   if jobs.f('procsel') = 2 then begin
  1872.     ssproc := etot_proc;
  1873.   End Else
  1874.   if jobs.f('procsel') = 3 then begin
  1875.     ssproc := jobs.f('proc_est');
  1876.   End;
  1877. end;
  1878.  
  1879.  
  1880. procedure JDrec.fsumbox;
  1881. begin
  1882.   sstot := ssmat + ssproc + tot_labor;
  1883.   ejob_tot:=0;
  1884.   if jobs.f('unit_price')<0 then begin
  1885.     job_bid:=abs(jobs.f('unit_price'))+tjob.otherchgs;
  1886.   End Else
  1887.   Begin
  1888.     job_bid:=(tot_ship * (jobs.f('unit_price')+tjob.otherup))+tjob.otherchgs;
  1889.   End;
  1890.   hjob_tot := job_tot;
  1891.   job_tot:=tot_labor + tot_mat + tot_proc;
  1892.   ejob_tot:=tot_labor + etot_mat + etot_proc;
  1893.   job_tot:=tot_labor;
  1894.   if jobs.f('matsel')=1 then begin
  1895.     job_tot := job_tot+tot_mat;
  1896.   End Else
  1897.   if jobs.f('matsel')=2 then begin
  1898.     job_tot := job_tot+etot_mat;
  1899.   End Else
  1900.   if jobs.f('matsel')=3 then begin
  1901.     job_tot := job_tot+jobs.f('mater_est');
  1902.   End Else Begin
  1903.     job_tot := job_tot+tot_mat;
  1904.   End;
  1905.   if jobs.f('procsel')=1 then begin
  1906.     job_tot := job_tot+tot_proc;
  1907.   End Else
  1908.   if jobs.f('procsel')=2 then begin
  1909.     job_tot := job_tot+etot_proc;
  1910.   End Else
  1911.   if jobs.f('procsel')=3 then begin
  1912.     job_tot := job_tot+jobs.f('proc_est');
  1913.   End Else Begin
  1914.     job_tot := job_tot+tot_proc;
  1915.   End;
  1916. end;
  1917.  
  1918.  
  1919. procedure JDrec.faoutsidt;
  1920. var yy:integer;
  1921. begin
  1922.   { job detail report outside costs program }
  1923.   jp.Line:=jp.Line+1;
  1924.   jp.p(jp.Line,1,'MATERIAL COST:');
  1925.   jp.p(jp.Line,17,transform(tot_mat,'9,999,999.99'));
  1926.   if Gen.AtPDS then begin
  1927.     mpsel(1,1);
  1928.   End;
  1929.   jp.p(jp.Line,40,'PROCESSING COST:');
  1930.   if Gen.AtPDS then begin
  1931.     mpsel(2,1);
  1932.   End;
  1933.   jp.p(jp.Line,63,transform(tot_proc,'9,999,999.99'));
  1934.   jp.Line := jp.Line + 1;
  1935.   ldpcosts;  { this proc in epart.prg }
  1936.   etot_mat:=0;
  1937.   etot_proc:=0;
  1938.   if mpcnt>0 then begin
  1939.     for yy:=1 to mpcnt do begin
  1940.       partclas.Seek(apclas[yy]);
  1941.       if (partclas.s('mat_proc')='M') Or (partclas.s('mat_proc')='C') then begin
  1942.         etot_mat:=etot_mat + (acost_ea[yy]*tot_ship);
  1943.       End Else
  1944.       Begin
  1945.         etot_proc:=etot_proc + (acost_ea[yy]*tot_ship);
  1946.       End;
  1947.     End;
  1948.   End;
  1949.   if Gen.AtPDS then begin
  1950.     jp.p(jp.Line,5,'ESTIMATED:');
  1951.     jp.p(jp.Line,17,lvblank(etot_mat));
  1952.     mpsel(1,2);
  1953.     jp.p(jp.Line,46,'ESTIMATED:');
  1954.     mpsel(2,2);
  1955.     jp.p(jp.Line,63,lvblank(etot_proc));
  1956.     jp.Line := jp.Line + 1;
  1957.     jp.p(jp.Line,0,'ADJUSTED TOTAL:');
  1958.     jp.p(jp.Line,17,lvblank(jobs.f('mater_est')));
  1959.     mpsel(1,3);
  1960.     jp.p(jp.Line,41,'ADJUSTED TOTAL:');
  1961.     mpsel(2,3);
  1962.     jp.p(jp.Line,63,lvblank(jobs.f('proc_est')));
  1963.   End Else
  1964.   Begin
  1965.     {  line = line + 1 }
  1966.     {  @ line,39 say "ESTIMATED:" }
  1967.     {  @ line,51 say lvblank(mater_est) }
  1968.     {  @ line,102 say "ESTIMATED:" }
  1969.     {  @ line,119 say lvblank(proc_est) }
  1970.   End;
  1971.   jp.Line:=jp.Line+2;
  1972.   ssmat := tot_mat;
  1973.   if jobs.f('matsel') = 2 then begin
  1974.     ssmat := etot_mat;
  1975.   End Else
  1976.   if jobs.f('matsel') = 3 then begin
  1977.     ssmat := jobs.f('mater_est');
  1978.   End;
  1979.   ssproc := tot_proc;
  1980.   if jobs.f('procsel') = 2 then begin
  1981.     ssproc := etot_proc;
  1982.   End Else
  1983.   if jobs.f('procsel') = 3 then begin
  1984.     ssproc := jobs.f('proc_est');
  1985.   End;
  1986. end;
  1987.  
  1988.  
  1989. procedure JDrec.fajdsumbox;
  1990. var lli:integer;
  1991. begin
  1992.   ejob_tot:=0;
  1993.   if jobs.f('unit_price')<0 then begin
  1994.     job_bid:=abs(jobs.f('unit_price'))+tjob.otherchgs;
  1995.   End Else
  1996.   Begin
  1997.     job_bid:=(tot_ship * (jobs.f('unit_price')+tjob.otherup))+tjob.otherchgs;
  1998.   End;
  1999.   if Not Gen.AtPDS then begin
  2000.     job_bid:=(jobs.f('qty') * jobs.f('unit_price'))+tjob.otherchgs;
  2001.   End;
  2002.   adjcom1:=jobs.s('jdnote1');
  2003.   adjcom2:=jobs.s('jdnote2');
  2004.   hjob_tot := job_tot;
  2005.   job_tot:=tot_labor + tot_mat + tot_proc;
  2006.   ejob_tot:=tot_labor + etot_mat + etot_proc;
  2007.   tot1:=0.00;
  2008.   tot2:=0.00;
  2009.   if Gen.AtPDS then begin
  2010.     jp.p(jp.Line,5,'ESTIMATED MATERIAL - PROCESS & LABOR COST FOR THIS PART');
  2011.     jp.p(jp.Line,70,'PARTS AND MATERIAL TO INVENTORY');
  2012.     jp.Line := jp.Line+1;
  2013.  
  2014.     jp.p(jp.Line,0,
  2015.       '*****************************************************************');
  2016.     jp.p(jp.Line,66,'****************************************');
  2017.     if jobs.f('unit_price')<0 then begin
  2018.       jp.p(jp.Line,108,'LOT PRICE');
  2019.     End;
  2020.     jp.Line := jp.Line+1;
  2021.  
  2022.     jp.p(jp.Line,0,'*  MATL-PROCESS-LABOR');
  2023.     jp.p(jp.Line,23,'LBS/UNIT');
  2024.     jp.p(jp.Line,33,'COST/LB');
  2025.     jp.p(jp.Line,42,'UNIT COST');
  2026.     jp.p(jp.Line,53,'TOTAL COST *');
  2027.     jp.p(jp.Line,66,'*                                      *');
  2028.     jp.p(jp.Line,108,'TOTAL BID:');
  2029.     jp.p(jp.Line,119,transform(job_bid,'9,999,999.99'));
  2030.     sumarr[1]:=sumarr[1]+job_bid;
  2031.     jp.Line := jp.Line+1;
  2032.  
  2033.     jp.p(jp.Line,0,'*  ------------------');
  2034.     jp.p(jp.Line,23,'--------');
  2035.     jp.p(jp.Line,33,'-------');
  2036.     jp.p(jp.Line,42,'---------');
  2037.     jp.p(jp.Line,53,'---------- *');
  2038.     jp.p(jp.Line,66,'* COMPLETE TO BLUEPRINT  :');
  2039.     if jobs.f('complete')>0 then begin
  2040.       jp.p(jp.Line,93,
  2041.               transform(jobs.f('complete'),'999,999,999'));
  2042.     End Else
  2043.     Begin
  2044.       jp.p(jp.Line,93,'___________');
  2045.     End;
  2046.     jp.p(jp.Line,105,'*');
  2047.     jp.Line := jp.Line+1;
  2048.  
  2049.     fashowest(1);
  2050.     jp.p(jp.Line,66,'* PARTIALLY COMPLETE     : ');
  2051.     if jobs.f('partial')>0 then begin
  2052.       jp.p(jp.Line,93,
  2053.               transform(jobs.f('partial'),'999,999,999'));
  2054.     End Else
  2055.     Begin
  2056.       jp.p(jp.Line,93,'___________');
  2057.     End;
  2058.     jp.p(jp.Line,105,'*');
  2059.     jp.p(jp.Line,107,'TOTAL COST:');
  2060.     jp.p(jp.Line,119,transform(sstot,'9,999,999.99'));
  2061.     sumarr[2]:=sumarr[2]+sstot;
  2062.     jp.Line := jp.Line+1;
  2063.  
  2064.     fashowest(2);
  2065.     jp.p(jp.Line,66,'* LESS  : ');
  2066.     if Not empty(jobs.s('less')) then begin
  2067.       jp.p(jp.Line,76,trim(jobs.s('less')));
  2068.       jp.p(jp.Line,105,'*');
  2069.     End Else
  2070.     Begin
  2071.       jp.p(jp.Line,76,'____________________________ *');
  2072.     End;
  2073.     jp.Line := jp.Line+1;
  2074.  
  2075.     fashowest(3);
  2076.     jp.p(jp.Line,66,'* LBS. MATERIAL IN STOCK : ');
  2077.     if jobs.f('material')>0 then begin
  2078.       jp.p(jp.Line,93,
  2079.               transform(jobs.f('material'),'999,999,999'));
  2080.     End;
  2081.     jp.p(jp.Line,105,'*');
  2082.     if Not numsequal(tjob.otherchgs,0) then begin
  2083.       jp.p(jp.Line,107,'BID INCLUDES '+
  2084.         ltrim(transform(tjob.otherchgs,'99,999.99'))+' ADJ.')
  2085.     End;
  2086.     jp.Line := jp.Line+1;
  2087.     fashowest(4);
  2088.     jp.p(jp.Line,66,'*--------------------------------------*');
  2089.  
  2090.               { @ line,107 say "TOTAL COST:" }
  2091.               { @ line,119 say ejob_tot pict "9,999,999.99" }
  2092.  
  2093.     jp.Line := jp.Line+1;
  2094.  
  2095.     fashowest(5);
  2096.     jp.p(jp.Line,66,'* COMMENT:'+padl(adjcom1,28)+' *');
  2097.     jp.Line := jp.Line+1;
  2098.  
  2099.     fashowest(6);
  2100.     if empty(jobs.s('clozapprov')) then begin
  2101.       jp.p(jp.Line,66,'*'+padl(adjcom2,37)+' *');
  2102.     End Else
  2103.     Begin
  2104.       jp.p(jp.Line,66,'*'+padl(adjcom2,37)+' *');
  2105.     End;
  2106.     jp.Line := jp.Line+1;
  2107.     if mpcnt<=6 then begin
  2108.       jp.p(jp.Line,0,
  2109.         '*****************************************************************');
  2110.       jp.p(jp.Line,66,'****************************************');
  2111.       jp.Line := jp.Line+1;
  2112.     End Else
  2113.     Begin
  2114.       for lli:=7 to mpcnt do begin
  2115.         fashowest(lli);
  2116.         if lli<=mpcnt then begin
  2117.           jp.p(jp.Line,66,'*                                      *');
  2118.         End;
  2119.         jp.Line := jp.Line+1;
  2120.       End;
  2121.       jp.p(jp.Line,0,
  2122.         '*****************************************************************');
  2123.       jp.p(jp.Line,66,'****************************************');
  2124.       jp.Line := jp.Line+1;
  2125.     End;
  2126.   End Else
  2127.   Begin
  2128.     jp.p(jp.Line,34,'EST LABOR COST:');
  2129.     jp.p(jp.Line,51,lvblank(jobs.f('labor_est')));
  2130.     jp.p(jp.Line,108,'TOTAL BID:');
  2131.     jp.p(jp.Line,119,lvblank(job_bid));
  2132.     jp.Line := jp.Line+1;
  2133.     jp.p(jp.Line,38,'LABOR COST:');
  2134.     jp.p(jp.Line,51,transform(tot_labor,'9,999,999.99'));
  2135.     jp.p(jp.Line,107,'TOTAL COST:');
  2136.     job_tot:=tot_labor+tot_mat+tot_proc;
  2137.     jp.p(jp.Line,119,transform(job_tot,'9,999,999.99'));
  2138.     jp.Line := jp.Line+1;
  2139.   End;
  2140. end;
  2141.  
  2142.  
  2143. procedure JDrec.fashowest(lnum:integer);
  2144. var ttst:string;
  2145. begin
  2146.   jp.p(jp.Line,0,'*'+transform(lnum,'9'));
  2147.   if (mpcnt>0) And (lnum<=mpcnt) then begin
  2148.     if partclas.Seek(apclas[lnum]) then begin
  2149.       ttst := partclas.s('descript');
  2150.     End Else
  2151.     Begin
  2152.       ttst := ' ';
  2153.     End;
  2154.     jp.p(jp.Line,jp.pCol,' '+upper(Copy(ttst,1,16)));
  2155.     if partclas.s('mat_proc')='P' then begin
  2156.       jp.p(jp.Line,21,transform(procwt,'9999.9999'));
  2157.     End Else
  2158.     Begin
  2159.       if partclas.s('mat_proc')='M' then begin
  2160.         jp.p(jp.Line,21,transform(matwt,'9999.9999'));
  2161.       End;
  2162.     End;
  2163.     jp.p(jp.Line,32,transform(acost_lb[lnum],'9999.99'));
  2164.     jp.p(jp.Line,41,transform(acost_ea[lnum],'9999.9999'));
  2165.     if Not empty(actual[lnum]) then begin
  2166.       jp.p(jp.pRow,jp.pCol,actual[lnum]);
  2167.     End;
  2168.     jp.p(jp.Line,52,transform(acost_ea[lnum]*tot_ship,'999,999.99'));
  2169.     if (partclas.s('mat_proc')='M') Or (partclas.s('mat_proc')='C') then begin
  2170.       tot1:=tot1 + (acost_ea[lnum])*tot_ship;
  2171.     End Else
  2172.     Begin
  2173.       tot2:=tot2 + (acost_ea[lnum])*tot_ship;
  2174.     End;
  2175.   End;
  2176.   jp.p(jp.Line,62,'  *');
  2177. end;
  2178.  
  2179. procedure JDrec.cloz5dbfs;
  2180. begin
  2181.     dbClose(jobs);
  2182.     dbClose(due);
  2183.     dbClose(ship);
  2184.     dbClose(labor);
  2185.     dbClose(outside);
  2186. end;
  2187.  
  2188. procedure JDrec.jbfstart(use_arch:integer);
  2189. begin
  2190.   if use_arch<0 then begin  { close all files except MainDBF's }
  2191.       dbClose(jobs);
  2192.       dbClose(due);
  2193.       dbClose(ship);
  2194.       dbClose(labor);
  2195.       dbClose(outside);
  2196.       dbClose(history);
  2197.       dbClose(partclas);
  2198.       dbClose(vendors);
  2199.       dbClose(emp);
  2200.       dbClose(cust);
  2201.       dbClose(parts);
  2202.       dbClose(tools);
  2203.       dbClose(jipinfo);
  2204.       dbClose(jobitems);
  2205.     end else begin
  2206.         if use_arch=1 then begin  { open other files needed }
  2207.             dbUse(history,jcpath('history'));
  2208.             dbUse(partclas,jcpath('partclas'));
  2209.             dbUse(vendors,compath('vendors'));
  2210.             dbUse(emp,compath('emp'));
  2211.             dbUse(cust,compath('cust'));
  2212.             dbUse(parts,compath('parts'));
  2213.             dbUse(tools,jcpath('tools'));
  2214.             dbUse(jipinfo,jcpath('jipinfo'));
  2215.             dbUse(jobitems,jcpath('jobitems'));
  2216.         End;
  2217.         if (use_arch=2) and (dbfsrc<>use_arch) then begin
  2218.             cloz5dbfs;
  2219.             dbUse(jobs,archpath('jobs'));
  2220.             dbUse(due,archpath('due'));
  2221.             dbUse(ship,archpath('ship'));
  2222.             dbUse(labor,archpath('labor'));
  2223.       labor.setorder(2);
  2224.             dbUse(outside,archpath('outside'));
  2225.         end;
  2226.         if (use_arch=3) and (dbfsrc<>use_arch) then begin
  2227.             cloz5dbfs;
  2228.             dbUse(jobs,temparch('jobs'));
  2229.             dbUse(due,temparch('due'));
  2230.             dbUse(ship,temparch('ship'));
  2231.             dbUse(labor,temparch('labor'));
  2232.       labor.setorder(2);
  2233.             dbUse(outside,temparch('outside'));
  2234.         end;
  2235.         if (use_arch=4) and (dbfsrc<>use_arch) then begin
  2236.             cloz5dbfs;
  2237.             dbUse(jobs,compath('jobs'));
  2238.             dbUse(due,jcpath('due'));
  2239.             dbUse(ship,jcpath('ship'));
  2240.             dbUse(labor,jcpath('labor'));
  2241.       labor.setorder(2);
  2242.             dbUse(outside,jcpath('outside'));
  2243.         end;
  2244.     end;
  2245.     dbfsrc:=use_arch;
  2246. end;
  2247.  
  2248. procedure JDrec.ldpcosts;
  2249. var ii:integer;
  2250.     tt:string;
  2251. begin
  2252.   for ii:=1 to 10 do apclas[ii]:='   ';
  2253.   for ii:=1 to 10 do apnote[ii]:=space(36);
  2254.   for ii:=1 to 10 do actual[ii]:=' ';
  2255.   for ii:=1 to 10 do acost_lb[ii]:=0.00;
  2256.   for ii:=1 to 10 do acost_ea[ii]:=0.00;
  2257.   matwt:=0.00;
  2258.   procwt:=0.00;
  2259.   split(parts.s('costclas'),':',pars,parscnt);
  2260.   mpcnt:=0;
  2261.   if parscnt>0 then begin
  2262.     mpcnt:=parscnt;
  2263.     for ii:=1 to mpcnt do begin
  2264.       apclas[ii] := Copy(pars[ii]+'   ',1,3);
  2265.     End;
  2266.     split(parts.s('lbs_ea'),':',pars,parscnt);
  2267.     if parscnt>2 then begin
  2268.       for ii:=1 to parscnt-2 do begin
  2269.         actual[ii] := pars[ii];
  2270.       End;
  2271.     End;
  2272.     split(parts.s('cost_lb'),':',pars,parscnt);
  2273.     for ii:=1 to mpcnt do begin
  2274.       acost_lb[ii] := ProcDbl(pars[ii]);
  2275.     End;
  2276.     split(parts.s('cost_ea'),':',pars,parscnt);
  2277.     for ii:=1 to mpcnt do begin
  2278.       acost_ea[ii] := ProcDbl(pars[ii]);
  2279.     End;
  2280.   End;
  2281.   tt:=parts.s('comments');
  2282.   if (Not empty(tt)) And (parscnt>0) then begin
  2283.     split(tt,':',pars,parscnt);
  2284.     for ii:=1 to parscnt do begin
  2285.       apnote[ii] :=pars[ii];
  2286.     End;
  2287.   End;
  2288.   split(parts.s('lbs_ea'),':',pars,parscnt);
  2289.   if parscnt>=2 then begin
  2290.     matwt:=ProcDbl(pars[parscnt-1]);  { Mat. weight }
  2291.     procwt := ProcDbl(pars[parscnt]);  { Process weight }
  2292.   End;
  2293. end;
  2294.  
  2295. procedure JDrec.histupdate(pJobRec:JobRec);
  2296. { used by both fastjbd and jbdet1 }
  2297. var kk,nn:integer;
  2298.     tt1:string;
  2299.         tj:JobRec;
  2300.     tt2,tupr,tt3:double;
  2301. begin
  2302.   { no longer update history if closed }
  2303.   if pos(Gen.User,'CONNIE DIANNE BRAD KATHLEEN KATHY ')=0 then begin
  2304.     Exit;
  2305.   End;
  2306.     tj:=pJobRec;
  2307.     { seek jobs->part_no+descend(jobs->job_no) }
  2308.     if history.Seek(tj.jobs.s('part_no')+tj.jobs.s('job_no')) then history.Lock
  2309.     else begin
  2310.         history.Append;
  2311.         history.ss('part_no',tj.jobs.s('part_no'));
  2312.         history.ss('job_no',tj.jobs.s('job_no'));
  2313.         history.ff('jstatus',tj.jobs.f('jstatus'));
  2314.     End;
  2315.     with tj do begin
  2316.         if ecnt>1 then begin
  2317.             for kk:=1 to ecnt do begin
  2318.                 DoEvents2;
  2319.                 for nn:=1 to ecnt-1 do begin
  2320.                     if eperc[nn]<eperc[nn+1] then begin
  2321.                         tt1:=enum[nn+1];
  2322.                         tt2:=eperc[nn+1];
  2323.                         tt3:=ehours[nn+1];
  2324.                         enum[nn+1]:=enum[nn];
  2325.                         eperc[nn+1]:=eperc[nn];
  2326.                         ehours[nn+1]:=ehours[nn];
  2327.                         enum[nn]:=tt1;
  2328.                         eperc[nn]:=tt2;
  2329.                         ehours[nn]:=tt3;
  2330.                     End;
  2331.                 End;
  2332.             end;
  2333.         End;
  2334.         history.ss('cust_no',jobs.s('cust_no'));
  2335.         history.dd('due_date',ssldue);
  2336.         history.ss('po_no',jobs.s('po_no'));
  2337.         history.ss('div_no',jobs.s('div_no'));
  2338.         history.ss('dep_no',jobs.s('dep'));
  2339.         history.ss('rev_no',jobs.s('rev_no'));
  2340.         history.dd('mot_date',jobs.d('mot_date'));
  2341.         history.ff('jstatus',jobs.f('jstatus'));
  2342.         history.dd('close_date',jobs.d('statdate'));
  2343.         history.ss('clozapprov',jobs.s('clozapprov'));
  2344.         history.ss('ourmat',jobs.s('ourmat'));
  2345.         history.dd('lastupdate',xDate);
  2346.         history.dd('orderdate',jobs.d('orderdate'));
  2347.         history.dd('setupdate',jobs.d('setupdate'));
  2348.         history.dd('porecdate',jobs.d('porecdate'));
  2349.         history.ss('emp1',enum[1]);
  2350.         history.ss('emp2',enum[2]);
  2351.         history.ss('emp3',enum[3]);
  2352.         history.ff('hours1',ehours[1]);
  2353.         history.ff('hours2',ehours[2]);
  2354.         history.ff('hours3',ehours[3]);
  2355.         history.ff('unit_price',jobs.f('unit_price')+tj.otherup);
  2356.         history.ss('joblink',jobs.s('joblink'));
  2357.         history.ff('qty_orderd',jobs.f('qty'));
  2358.         history.ff('qty_shippd',ssship);
  2359.         history.bb('otheritems',jobs.b('otheritems'));
  2360.         history.dd('final',sslship);
  2361.         if jobs.f('unit_price')<0 then begin
  2362.             { lot price }
  2363.             history.ff('bid',-jobs.f('unit_price')+ssadj);
  2364.         End Else
  2365.         Begin
  2366.             history.ff('bid',(ssship*jobs.f('unit_price'))+ssadj);
  2367.         End;
  2368.         if Gen.AtPDS then begin
  2369.             history.ff('est_mater',etot_mat);
  2370.             history.ff('est_proc',etot_proc);
  2371.             { calc est labor using unit price less mat/proc share }
  2372.             if ssship>0 then begin
  2373.                 tupr:=(etot_mat+etot_proc)/ssship;
  2374.                 history.ff('labor_est',(history.f('unit_price')-tupr)*ssship);
  2375.                 if history.f('labor_est')<0 then begin
  2376.                     history.ff('labor_est',0);
  2377.                 End;
  2378.             End;
  2379.         End Else
  2380.         Begin
  2381.             history.ff('est_mater',history.f('mater_est'));
  2382.             history.ff('labor_est',history.f('labor_est'));
  2383.             history.ff('est_proc',history.f('proc_est'));
  2384.         End;
  2385.         history.ff('labor_act',tot_labor);
  2386.         history.ff('act_mater',ssmat);
  2387.         history.ff('act_proc',ssproc);
  2388.         history.ff('ttl_hours',hjob_tot);
  2389.         history.ff('complete',jobs.f('complete'));
  2390.         history.ff('partial',jobs.f('partial'));
  2391.         history.ss('less',jobs.s('less'));
  2392.         history.ff('material',jobs.f('material'));
  2393.     end;
  2394.     history.unLock;
  2395. end;
  2396.  
  2397.  
  2398. End.
  2399.